/** * * Monitor Home key * /private Broadcastreceiver mhomekeyeventreceiver = new Broadcastreceiver () { String System_reason = "REASON"; String System_home_key = "HomeKey"; String System_home_key_long = "Recentapps"; @Override public void OnReceive (context context, Intent Intent) { String action = intent.getaction (); if (Action.equals (intent.action_close_system_dialogs)) { String reason = Intent.getstringextra (System_reason); if (textutils.equals (reason, System_home_key)) { //indicates that the HOME key is pressed, the program is in the background appconfigmanager.getinstance (). Setlastisplayflag ((Mfgplayer! = null)? Mfgplayer.isplaying (): false); } else if (textutils.equals (reason, System_home_key_long)) { //= long press the HOME key to display the list of recently used Programs}}} };
Remember to register for the broadcast:
Registerreceiver (Mhomekeyeventreceiver, New Intentfilter ( intent.action_close_system_dialogs));
Android Monitor Home button