2.2 Disable the System home key, not here to say.
Recent projects have a requirement to disable all keys for the system, like menu, home, back. Also, if you want to click the response and view pop-up. Is that the UI part is normal.
Back key our own onkeydown disabled good happy.
Personally think the simplest wording, please visit:
http://blog.csdn.net/yiding_he/article/details/38527813
The key here is to disable the system home key after 4.0.
On the internet for a long time, basically it is not available. Because it's all about system security, the Android system absorbs the event (Home,menu) at the framework level and is not distributed to the application layer at all.
The Menu key can ' t be disabled for security reasons, this key is handled by the framework and is never delivered to Applic Ations.
http://stackoverflow.com/questions/15459407/disable-home-button-in-android-4-0
See, the Foreigner's stack overflow said there is no way.
As I approached the disappointment, casually entered a search page in a big God's github,https://github.com/shaobin0604/android-homekey-locker, casually downloaded to try, unexpectedly work.
More importantly, the great God is our Chinese. It's too bull.
Worship, here does not dwell on how the great God is realized, the secret is to build a overlaydialog, give it set some parameters like flag_show_when_locked,flag_not_touch_modal and so on.
Students who want to study, please download the source code to learn.
Here are just a few words to use:
1. To Https://github.com/shaobin0604/Android-HomeKey-Locker, download the Code of the Great God.
The Homekeylocker.java in 2.HomeLockLib is placed under its own util package.
Overlaydialog related portions of styles in 3.HomeLockLib are copied to their styles.
4. Join in your own androidmanifest
< uses-permission android:name="Android.permission.SYSTEM_ALERT_WINDOW"/>
5. New Homekeylocker object where you want to lock the key.
Private Homekeylocker Mhomekeylocker;mhomekeylocker = new Homekeylocker ();
After that, you need to use the LOCK key:
Mhomekeylocker. Lock (mactivity. this);
Unlock using:
Mhomekeylocker.unlock ();
6. In your own Destroy method, add:
@Overrideprotected void OnDestroy () {Super.ondestroy (); Mhomekeylocker.unlock (); mhomekeylocker = null;}
So that you can play happily.
Android 4.0 disable System Home key