Android Activity life cycle exception

Performance status:

1. Start activityB in activityA, note that there is no finish operation in this process;

2. Finish yourself in activityB;

3. Go back to activityA and find that the original member variables are all cleared/null, and the onCreate method is executed

 

Expected situation:

It should be that activityA retains the values ​​of all member variables and starts executing from the onStart method

 

possible reason:

1. The worst case should be that the system memory is full and activityA is forcibly released, but the possibility is relatively low;

2. A very important place that is easily overlooked: Settings -> Developer Options, pull it all the way to the bottom, there is an option " Do not keep activities (destruct each activity after the user leaves) ", here if it is If the wrong operation is selected, it will affect the default life cycle of Android! ! !

 

 

 

 

Guess you like

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