This is an Android learning note about the home key
The question of the proposed
The Android Home Key System is responsible for monitoring and capturing the system to automatically process it. Sometimes, the processing of the system often does not follow our intention, want to deal with the event after clicking Home, then how to do?
Solution to the problem
First prohibit the home button, and then in the onkeydown process key value, click the Home button when the program shut down, or as you xxoo.
@Override Public
boolean onKeyDown (int keycode, keyevent event)
{//TODO auto-generated method stub
if ( Keyevent.keycode_home==keycode)
android.os.Process.killProcess (Android.os.Process.myPid ());
Return Super.onkeydown (KeyCode, event);
}
@Override public
void Onattachedtowindow ()
{//TODO auto-generated the method stub
This.getwindow (). SetType (WindowManager.LayoutParams.TYPE_KEYGUARD);
Super.onattachedtowindow ();
}
Add permission to prohibit home key
<uses-permission android:name= "Android.permission.DISABLE_KEYGUARD" ></uses-permission>
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/