Get the home button press message under Android
Under Android, it is not possible to intercept the home key message through events such as onkeydown, for reasons that have been explicitly stated in the Android documentation
Translation will not do, in short, the app can not intercept the Home button event (there was a high man in the 2.3 below the system, using the method to intercept home, but after 4.0 has been invalidated, so do not mention)
Then, how to get the home button to press the message, the method or some, in this need to be explained, because of the particularity of the home key, its logic within the framework is processed, so can not intercept/block home key, but only to get its message, but after the message is received, If you want to get back to the background of the app to start up again, it is not impossible (the interface will flash)
The following code captures the press message to the home key:
At the same time, we also need to register this receiver in the program in order to make it effective
In this way, in the above two todo places, you can add their own code, it should be noted that after 4.0, the home key may have two reason, the original home and display the most recent application, in receiver, by judging the reason string, can be processed separately.
Home button to get listening, Android 4.0 can not be obtained in the OnKeyDown method. What to do.