Android finish does not execute ondestory ()

Source: Internet
Author: User

If you want to save data or have data-related operations, it is best to do so in the OnPause function, because the OnDestroy function may not execute.

There is situations where the system would simply kill the activity ' s hosting process without calling this method (or any Others) in it, so it should is used to does things that is intended to remain around after the process goes away.

The above is the official website, the meaning is that, there are many situations in which the system will simply kill the activity of the host process without invoking its OnDestroy method, so in this method do not do anything about preserving data or state related operations.

This is a life cycle diagram of the activity of the official website, and we can see that the activity has two exits, and OnStop may go directly to the APP process killed without executing the OnDestroy function.

Android finish does not execute ondestory ()

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.