I. The role of each method in the life cycle of the activity
OnCreate (): The initialization of the data needed to do the activity.
OnStart (): Displays the activity interface, at which time the user is visible to the interface but not interactive.
Onresume (): At this point the user can interact with the app and do what you want to do.
OnPause (): The user is visible but not interactive at this point, or the interface has no focus at this time, such as a popup dialog box.
OnStop (): The interface becomes invisible at this point and is overwritten or minimized by the next activity.
OnDestroy (): This is the last method to be called before the activity is killed.
Second, the process of invoking the life cycle method
1. When activity is started: OnCreate ()-->onstart ()-->onresume () and interacting with the user
2.onPause ()-->onresume ()
OnPause (): Not interactive at this time, usually jumping out of the dialog box. At this point you will save some of your data---transient data,
Because this time the priority of the program is reduced, it is possible to be recovered by the system. When returning, call Onresume () at Onresume () to read the
The saved data.
Note: This is done in a short time, because the next activity (): will not wait until this method is completed before starting
3.onPause ()-->onstop ()-->onstart ()-->onresume () cannot see visible and interactive
When activity is minimized or overwritten by other activity---activity is not visible at this time, the process of re-invoking the activity (this refers to
The activity is not killed by the system);
Another: If at this time the covered activity was killed by the system, the general is to restart the activity, the cycle will start again.
4.onPause ()-->onstop ()-->ondestroy ()
This is the process of activity being killed. We need to write down resources in the OnDestroy () method, such as the service associated with the activity,
Background threads, and so on.
The life cycle of activity and the role of various life cycle methods