The life cycle of Activity is roughly as follows:
onCreate, onStart, onResume, onRestart, onPause, onStop, onDestroy.
The following is the calling sequence of life cycle methods for several common scenarios:
Assume that the activity to be tested is Activity1, the other Activity is Activity2, and the life cycle method calls refer to those in Activity1.
打开Activity1:
onCreate->onStart->onResume
Open Activity2 in Activity1:
onPause->onStop
Close Activity2 and return to Activity1:
onRestart->onStart->onResume
关闭Activity1:
onPause->onStop->onDestroy