How to detect “Recent Apps” system button clicks (Honeycomb+)

前端 未结 8 762
一个人的身影
一个人的身影 2020-11-30 05:37

I\'m wondering what method this button calls.

\"enter

My game always pauses/re

8条回答
  •  伪装坚强ぢ
    2020-11-30 06:30

    The best way I have found is listent to Broadcast Action called "ACTION_CLOSE_SYSTEM_DIALOGS".From the Google docs:

    Broadcast Action: This is broadcast when a user action should request a temporary system dialog to dismiss. Some examples of temporary system dialogs are the notification window-shade and the recent tasks dialog.

    Working code:

    IntentFilter intentFilterACSD = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    
        BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
                        //do what you want here
                }
            }
        };
        this.registerReceiver(broadcastReceiver, intentFilterACSD);
    

提交回复
热议问题