1760 reading comments (13)
Favorites
Report
This is an android study note about the home key.
Proposal of proposal
The android HOME key system is responsible for monitoring and automatically processes the captured data. Sometimes, the processing of the system often does not mean anything. What should we do if we want to handle the event after clicking home on our own?
Solution to the Failover Problem
Disable the Home key first, and then process the key value in onkeydown. When you click the Home Key, close the program or follow your 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 method stub
This. getwindow (). settype (windowmanager. layoutparams. type_keyguard );
Super. onattachedtowindow ();
}
Add the permission to prohibit the Home Key
<Uses-Permission Android: Name = "android. Permission. disable_keyguard"> </uses-Permission>
This is an android study note about the home key.
Proposal of proposal
The android HOME key system is responsible for monitoring and automatically processes the captured data. Sometimes, the processing of the system often does not mean anything. What should we do if we want to handle the event after clicking home on our own?
Solution to the Failover Problem
Disable the Home key first, and then process the key value in onkeydown. When you click the Home Key, close the program or follow your 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 method stub
This. getwindow (). settype (windowmanager. layoutparams. type_keyguard );
Super. onattachedtowindow ();
}
Add the permission to prohibit the Home Key
<Uses-Permission Android: Name = "android. Permission. disable_keyguard"> </uses-Permission>