(Life cycle of the first line of Android code activity) life cycle

Source: Internet
Author: User

Life cycle of activities

Mastering the life cycle of an activity is important to any Android developer, and when you understand the life cycle of an activity, you can write more consistent and streamlined programs, and you'll be able to manage your application resources wisely. Your application will have a better user experience.

    • Back to Stack

1. Definition: Android is a task to manage activities, a task is a set of activities stored in the stack this stack is also known as the return stack (back stack).

2. Top of the stack: Store a new activity that has just started. (When we press the back key or call the finish () method to destroy an activity, the activity at the top of the stack is out of the stack, and the previous activity on the stack is re-positioned at the top of the stack. The system always displays the activity at the top of the stack to the user. )

    • Activity status

1. Operational status: when the activity is at the top of the stack at the return stack (the last thing the system would like to recycle is a running activity, because it brings a very poor user experience.) )

2. Paused state: When an activity is no longer in the top position of the stack, but is still visible (such as a new dialog box activity above an activity that activity is to suspend the activity-the system is not willing to recycle this activity.) )

3. Stop state: When an activity is no longer at the top of the stack and is completely invisible, it enters the stop state. (The system will still save the appropriate state and member variables for this activity, but it is easy to recycle)

4. Destroy state: When an activity is removed from the return stack it becomes the destruction state (the system will most likely recycle the activity in this state to ensure that the phone has sufficient memory.) )

(Life cycle of the first line of Android code activity) life cycle

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.