Activity is the basic of Android development in every project that will have activity. Activity has its own life cycle, there are many blogs and materials on the Internet, here I just confirm.
An activity:
There are three ways to go when you open an activity
OnCreate
OnStart
Onresume
When you click Fallback activity
OnPause
OnStop
OnDestroy
When I click on the home button
OnPause
OnStop
Open the app again
Onrestart
OnStart
Onresume
When the program crashes, don't walk the life cycle
When there are two activity, the first activity name is tentatively positioned Frist, and the second one is second
When you start the first activity
Frist:oncreate
Frist:onstart
Frist:onresume
When you open a second activity
Frist:onpause
Second:oncreate
Second:onstart
Second:onresume
Frist:onstop
When the second activity is rolled back
Second:onpause
Frist:onrestart
Frist:onstart
Frist:onresume
Second:onstop
Second:ondestroy
In the second activity click Home
Second:onpause
Second:onstop
Open the app again
Second:onrestart
Second:onstart
Second:onresume
Activation mode of activity
Standard: Normal mode, each time an activity is started, a new instance will be built, regardless of whether the instance already exists
Singletop: Stack top multiplexing mode, if the new activity is already at the top of the task station's stack, then the activity will not be recreated, and its Onnewintent method will be called, and the parameters of this method can be used to fetch the information of the current request.
Singletask: In-stack multiplexing mode, which is a single-instance mode in which the activity is not recreated as long as it exists in a stack, and as with Singletop, the system calls its onnewintent
Singleintance: Single-instance mode, a strengthened Singletask mode, in addition to having all the features of the Singletask mode, the activity of this mode can only be isolated in the task stack, due to the characteristics of the reuse in the stack, Subsequent requests do not create new activity unless the task stack is destroyed by the system
GitHub Address Https://github.com/tempest1/AndroidActivity
Life cycle and startup mode for Android activity