System. Exit (0); and finish ();, push Principle

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.