Android: Programmatically open “Recent Apps” dialog

前端 未结 3 1577
梦毁少年i
梦毁少年i 2020-12-05 11:42

I would like to be able to open the \"Recent Apps\" dialog from my application. This is the dialog that is opened by long-pressing the home button. I am programming for Andr

3条回答
  •  攒了一身酷
    2020-12-05 12:37

    This can be done using the TOGGLE_RECENTS Intent.

    Intent intent = new Intent ("com.android.systemui.recent.action.TOGGLE_RECENTS");
    intent.setComponent (new ComponentName ("com.android.systemui", "com.android.systemui.recent.RecentsActivity"));
    startActivity (intent);
    

    Note Package would be changed basis on Api level. See here.

    Android 4.1: "com.android.internal.policy.impl.RecentApplicationsDialog"
    Android 4.2 - 4.4: "com.android.systemui.recent.RecentsActivity"
    Android 5.0 - 7.1: "com.android.systemui.recents.RecentsActivity" ("s" letter was added)
    

提交回复
热议问题