The life cycle of the first lesson Activity

 

1. Activity life cycle under typical conditions

onCreate->onStart->onResume->onPause->onStop->onDestroy, call onStart when the user returns to the original Activity after onStop

2. Activity life cycle under abnormal conditions

2.1 Resource-related system configuration changes cause Activity to be killed and recreated

System configuration changes (such as horizontal screen change to vertical screen): call onPause, onStop, onDestroy once, call onSaveInstanceState before onStop to save the current information, the save method has no time sequence relationship with onPause; call onCreate and onRestoreInstanceState to restore the data when the Activity is recreated , The onRestoreInstanceState method is after the onStart method.

2.2 Insufficient resource memory causes low-priority Activity to be killed

The method call process is the same as 2.1, Activity priority from high to low: foreground Activity, visible but not foreground Activity, background Activity

 

Guess you like

Origin blog.csdn.net/wishxiaozhu/article/details/114598981