How to ignore button click of “Recent Activity Button” in android 3.0

强颜欢笑 提交于 2019-11-28 09:33:16
Lukas Knuth

From peeking into the docs, I think that KeyEvent.KEYCODE_APP_SWITCH is what you're searching for.

You could however also use the KeyEvent.getKeyCode()-method (on the event-parameter) to see which key-code is triggered (and if there is any key triggered), when you press the application switcher.


I played around with this for a while and I have come to the conclusion, that it's not possible.

The KEYCODE_APP_SWITCH-event is not delivered to either onKeyDown() nor dispatchKeyEvent(). Ergo, It can not be handled.

Also, you'll run into problems on Android 4 devices, because the KEYCODE_HOME-event is also no longer dispatched to any of the above methods. See the docs:

Key code constant: Home key. This key is handled by the framework and is never delivered to applications.


It also seems that there is no real easy approach to creating a real lock-screen yourself. See this discussion: Developing a custom lock screen

It is well possible to show some custom information on the default lock-screen: Is there a way for me to show a customized message on the lock screen?


For the sake of completeness: In Android L, you'll be able to "lock users in your app", so you don't need to manually override the Hardware keys. Here's the relevant information:

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

JohnyTex

If you want to run your app rooted in Kiosk-mode, then it might be possible to disable com.android.systemui and replace buttons by soft buttons (for instance the Button Saviour app, though be careful not to brick your device!). It seems a lot of cosmetic stuff disappears and I don't know if it affects system stability in some unknown way, but I have made it work so far.

If anyone knows more about com.android.systemui, what it really does and if it is safe to disable it, please comment!

Also see my post: Safe to disable com.android.systemui?

where I hope to get some answers...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!