Common interview questions for Android development Activity jump life cycle changes

Now, if you ask about the life cycle, you will generally not ask 7 but will ask you about the changes in the life cycle of two pages in succession:

For example, when ActivityA-> jumps to ActivityB, the continuous life cycle of the two pages is as follows:

2020-09-07 17:31:28.585 5582-5582/? E/生命周期_MainActivity: onPause
2020-09-07 17:31:28.651 5582-5582/? E/生命周期_SingleInstance: onCreate
2020-09-07 17:31:28.655 5582-5582/? E/生命周期_SingleInstance: onStart
2020-09-07 17:31:28.657 5582-5582/? E/生命周期_SingleInstance: onResume
2020-09-07 17:31:29.158 5582-5582/? E/生命周期_MainActivity: onStop

Explain the above life cycle changes:

首先ActivityA->onPause->ActivityB:onCreate->onStart->onResume->ActivityA:OnStop

 

 

The above steps are the continuous life cycle of ActivityA jumping to ActivityB, then press the return button at this time, how should the life cycle go?

In fact, it is very simple as shown above:

ActivityB->onPause->ActivityA->onRestart->onStart->onResume-ActivityB->onStop->onDestory

Guess you like

Origin blog.csdn.net/xiayiye5/article/details/108452385