Activity life cycle
Activity status is managed by the Android active Stack, which is currently active at the top of the stack. As different applications run, each activity is likely to move from active to inactive, from inactive to active state.
Activity induction is roughly 4 states:
1. Active Status: The current activity is located in the foreground, the user is visible, can get the focus;
2. Suspend status: Other activity is located in the foreground, the activity is visible, cannot get the focus;
3. Stop state: The activity is not visible, lose focus;
4. Destruction Status: The activity ends, or the activity's Dalvik process is ended (Dalvik is Google's own virtual machine designed for Android platforms).
For example, the activity life cycle and related callback methods are shown:
1. Start activity: The system calls the OnCreate method first, then calls the OnStart method, and finally calls Onresume,activity into the running state.
2. Current activity is overwritten or locked by other activity: the system invokes the OnPause method, pausing the execution of the current activity.
3. The current activity is returned to the foreground or unlock screen by the overwritten state: The system calls the Onresume method and enters the running state again.
4. The current activity goes to the new activity interface or press the home key to return to the main screen, itself back to the background: the system will first call the OnPause method, and then call the OnStop method, into a stagnant state.
5. The user backs back to this activity: the system calls the Onrestart method first, then calls the OnStart method, and finally calls the Onresume method, again into the running state.
6. Current activity is in a covered state or the background is not visible, that is, the 2nd and 4th steps, the system is out of memory, kill the current activity, and then the user returned to the current activity: Call OnCreate method Again, OnStart method, Onresume method To enter a running state.
7. The user exits the current activity: The system calls the OnPause method first, then calls the OnStop method, and finally calls the Ondestory method to end the current activity.
Attention:
Activity is actually inheriting the ApplicationContext class, like-from eclipse:
Android Learning Note 28--activity life cycle