Activity Lifecycle
The Activity class provides a number of callbacks that allow the activity to know that a state has changed, that the system is creating, stopping, or resuming an activity, or destroying the process in which the activity resides.
LifeCycle’s methods sequence
Get Sohan Gupta’s stories in your inbox
Join Medium for free to get updates from this writer.
onCreate() -> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()
Lifecycle callbacks when one activity comes on top of another
Starting activity2 from the activity1’s onCreate() method as follows
@Override
protected void onCreate(Bundle savedInstanceState) { Intent intent = new Intent(this, Activity2.class);
startActivity(intent);}
Note: onCreate() of activity1 is already called as activity2 is being called from there.
What happens when press back button on Activity 2: See all the callbacks of activity 1 and activity 2 in below diagram







