我想启动显示最近使用的应用程序的菜单。
我尝试在按下按钮时查看 logcat,希望有一些我可以启动的 Intent ,但没有成功。
我知道在某些手机上它是一个专用按钮,也可以通过长按主页按钮来实现。有什么方法可以以编程方式启动它吗?
编辑:更新标题更准确
最佳答案
当您按下“最近的应用程序”按钮时,logcat 将输出以下消息:
568-716/system_process I/ActivityManager﹕ START u0 {act=com.android.systemui.recent.action.TOGGLE_RECENTS flg=0x10800000 cmp=com.android.systemui/.recent.RecentsActivity} from pid 627
--------- beginning of /dev/log/main
568-582/system_process I/ActivityManager﹕ Displayed com.android.systemui/.recent.RecentsActivity: +215ms
因此,我们可以通过编程方式模拟此操作。 (不要忘记将标志设置为 0x10800000):
Intent intent = new Intent ("com.android.systemui.recent.action.TOGGLE_RECENTS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.setComponent(new ComponentName("com.android.systemui", "com.android.systemui.recent.RecentsActivity"));
startActivity (intent);
关于RecentsActivity
的更多信息,请阅读源码here .
关于android - 如何在 android 中启动最近的应用程序菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12344738/