首先就是键的名称
安卓底部有三个键,返回键,home键,菜单键(?)
返回键,home键的说明没有争议。
菜单键就有很多说法了:
recent apps list,Task Switcher,Recent Tasks button,Overview,多任务键。(戻る,ホーム,マルチタスク) API 11之后KeyCode就变成了KEYCODE_APP_SWITCH, 确实在adb里输入adb shell input keyevent KEYCODE_APP_SWITCH,反应跟按下菜单键一样。 参考Android菜单键的前世今生https://www.jianshu.com/p/c54897f2924c
The overview button is the square button in the black bar along the bottom of your device screen button navigation: Three buttons for Home, Back, and App Overview. he Recents screen (also referred to as the Overview screen, recent task list, or recent apps)
返回键 onKeyDown里就可以捕捉到keyCode是 KEYCODE_BACK home键可以通过注册一个BroadcastReceiver来捕捉。参考https://blog.csdn.net/weixin_33873846/article/details/89695354 在低版本里,也可以不捕捉到菜单键。但是在高版本(8.0以上)就不好使了。
按下菜单键,虽然onUserInteraction,onUserLeaveHint,onPause,onStop也会被触发,但是无法区分是画面跳转触发,还是按下菜单键触发。
Activity的startLockTask(),可以让home,recent(最近)暂时失效。不过画面上会有提示。https://blog.csdn.net/zhenbohuang/article/details/72722247
有设备权限的话,可以无效化这三个系统键 lab.sonicmoov.com/development/app-dev/android-kiosk/
参考
[深入SystemUI]-了解recents的启动流程(一)https://blog.csdn.net/weixin_42832981/article/details/89499559
[Android] [SystemUI] Recent -- 最近任务的启动流程https://blog.csdn.net/libelosophy/article/details/30222275
【Android】详解Android的menu菜单https://www.cnblogs.com/HDK2016/p/8038908.html
Android 9.0 的 recent 键/事件的拦截https://blog.csdn.net/Easyhood/article/details/95637143
Android Recent键的点击事件https://blog.csdn.net/qq_27256793/article/details/101421234
Android如何屏蔽home键和recent键https://blog.csdn.net/zhenbohuang/article/details/72722247
Android中切换到主线程更新方法https://blog.csdn.net/u010520146/article/details/82108583
最近使用的应用”屏幕 https://developer.android.com/guide/components/activities/recents#sample
独自のユーザー補助サービスを作成する https://developer.android.com/guide/topics/ui/accessibility/service?hl=ja
最近の画面 https://developer.android.com/guide/components/activities/recents?hl=ja#kotlin