1.1. 在AndroidManifest.xml中加上权限,禁止HOME键。
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
public static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;
public void onAttachedToWindow(){
getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED,FLAG_HOMEKEY_DISPATCHED);
super.onAttachedToWindow(); }
- public boolean dispatchKeyEvent(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.KEYCODE_HOME)
- return true;
- }