Today, my sister asked me about the android background. I remembered how to "exit without resident memory" when I made a hexadecimal conversion a few years ago 」. Although Android does not recommend that you manually close the process, you have to consider the memory when the memory is insufficient.
First, directly press the back key, and the memory will certainly reside. Second, finish () can also end the activity, but also resident the memory (I clearly remember that I did the experiment at the time, industry conscience ). I tried many methods and finally found a method to exit:
Add the back key listener to the underlying activity, and use this method in onclick:
System. Exit (0 );
The principles are as follows:
Terminate the currently running Java virtual machine. This method never returns normally. A variable can be used as a status code. A non-zero status code indicates an abnormal termination.
In addition, I have never been confused about push, especially the third-party push. It seems that there are various referers. I can find an answer on zhihu:
IOS push: It is Apple's official apns (Apple push notification service ).
Android push: Google's official GCM (Google cloud messaging ).
Essentially, apns and GCM are similar technical implementation principles: that is, the system layer has a resident TCP persistent connection, which is always maintained, persistent connections are maintained even when the phone is sleeping.
IOS is truly responsible for user experience and does not allow applications to be active in the background. With this restriction, it is necessary for an application to "notify" the user of the terminal device and actively communicate with the user at any time (such as a typical chat application ).
This is the logic of apns: IOS keeps a persistent connection in the background. All applications can be transferred to the user through apns if they are necessary (applied) and allowed (users can change their settings.
System. Exit (0); and finish ();, push Principle