Bor*_*per 4 android android-intent
我想启动显示最近使用的应用程序的菜单。
我试着在按下按钮时查看 logcat,希望有一些我可以启动但没有运气的意图。
我知道在某些手机上它是一个专用按钮,也可以通过长按主页按钮来实现。有什么方法可以以编程方式启动它吗?
编辑:更新标题更准确
当您按下“Recent Apps”按钮时,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
Run Code Online (Sandbox Code Playgroud)
所以,我们可以通过编程来模拟这个操作。(不要忘记将标志设置为 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);
Run Code Online (Sandbox Code Playgroud)
有关更多信息RecentsActivity,请阅读此处的源代码。
| 归档时间: |
|
| 查看次数: |
13311 次 |
| 最近记录: |