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.
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. )
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