Override these two methods:
@ Override
Public Boolean onkeydown (INT keycode, keyevent event ){
// Todo auto-generated method stub
Intent intent = new intent (intent. action_main );
If (keyevent. keycode_home = keycode ){
Do something ...... // capture the Home Key to do your own thing
Intent. setflags (intent. flag_activity_new_task); // if it is called in a service, the new task id must be added.
Intent. addcategory (intent. category_home );
Startactivity (intent );
}
Return super. onkeydown (keycode, event );
}
@ Override
Public void onattachedtowindow (){
// Todo auto-generated method stub
This. getwindow (). settype (windowmanager. layoutparams. type_keyguard );
Super. onattachedtowindow ();
}
However, there is a small problem: when you exit the application, half a black screen will pop up. I don't know why. If you know, please leave a message to make progress together. Thank you!