The difference between finish () OnDestroy () and System.exit () in Android development-activity

Source: Internet
Author: User

Activity.finish ()
Call the When the your activity is do and should be closed.
Call this method when your activity is completed, or when the activity needs to be closed.
When you call this method, the system simply moves the top activity out of the stack and does not call the Ondestory () method in a timely manner, and its resources are not released in a timely manner. Because the stack is removed, you won't find the activity when you click on the "Back" button on your phone.
Activity.ondestory ()
The system is temporarily destroying this instance of the activity to save space.
The system destroys the space occupied by the instance of the activity in memory.
During the activity life cycle, the Ondestory () method is the last step of his life, and the resource space is recycled. When you re-enter this activity, you must recreate and execute the OnCreate () method.
System.exit (0)
This thing is out of the entire application and is for the entire application. The entire process is directly KO dropped.

------------------------------------------

The finish function simply exits the current activity, but does not release his resources. The Android system itself decides when to release the application from memory. When the system does not have available memory, it will release some of the apps by priority.

The difference between finish () OnDestroy () and System.exit () in Android development-activity

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.