android life cycle

When the activity is first created

When a dialog pops up, there is no change in the life cycle, it is still the same as before, because the dialog belongs to the activity

When jumping to other interfaces, onPause and onStop are triggered

When jumping back to the previous interface again, onStart, onResume, and onPostResume will be triggered

When the home button is pressed, onPause and onStop are triggered, and the life cycle is the same as that of jumping to other interfaces, and the essence is the same

When destroying the interface, the life cycle taken is onPause, onStop, onDestroy, and onDestroy is called more than before.

 

The difference between onstop and onPause:

When a normal dialog is created, neither side is called

When an activity dialog is created, onpause is called, onstop is not called

When onpause, when the activity part is not visible, it will be triggered

onstop is triggered when the activity is completely invisible. If the theme of the new activity is transparent, onstop will not be called

 

The difference between onstart and onrestart:

When the activity is created, only onstart will be called and onrestart will not be called.

onstart is called every time the activity changes from invisible to visible.

onstart can be understood as a paired appearance with onstop

cp relationship

onstart-onstop

onresume-onpause

Lifecycle in Exceptional Conditions

onsaveInstanceState is called only in exceptional circumstances, such as rotating the screen, the original activity will be destroyed, and onsaveInstanceState will be called

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325259153&siteId=291194637