"Android Dev-7" life cycle, activity's sickness and death

Source: Internet
Author: User

Life and death is something that everyone has to go through. So don't panic, calm down and think about what you should do at each stage of your life in order to improve your life value, or increase your own value. In one life cycle, what is done at a certain stage, not completed, may affect the entire life cycle. So sometimes life can not degenerate, a fall may be a lot of good things will be missed, waiting for you only the Silent confession!


For the life cycle of the activity process, the most classic picture is as follows:



1. When an activity a starts, it goes through each of the following stages:

OnCreate ()-->onstart ()-->onresume ()

2. When another activity B is being opened,activity A can also be seen when the stage goes through:

OnPause ()

3. When another activity B is opened andactivity A is not visible , the stage goes through:

OnStop ()

4. When activity b is closed, go back to activity a and go through the stages:

Onrestart ()-->onstart ()-->onresume ()

5. When activity a closes, it goes through the stages:

OnDestroy ()

6. Or when activity A is in the OnPause and OnStop state, when the higher priority apps require memory, and the system memory is not enough, then the Android system kills the process where ctivity A resides to free up resources . So we're back in the 1 phase.


Toss an example to understand the following:



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.