The Android Lifecycle Cheat Sheet — Part II: Activity Lifecycle

Part I — Application Process Part I I — Activity Lifecycle 👉 You are here📍 Part I I I — Avoid This Mistakes (Activity Lifecycle) Part IV — Intro to Fragment Lifecycle Part V — Fragment View Lifecycle 👉 Upcoming ⏰ Part VI — View Model Lifecycle 👉 Upcoming ⏰
What is a Lifecycle?
It is the specification of an object’s creation and destruction times, along with a set of special callback methods that the system automatically invokes in response to specific events.
What is an Android Activity?
Among other functions it acts as a screen area controller. This implies that the screen is a shared resource among different applications, leading to various implications:
- The OS should be capable of transferring control over windows from one Activity to another.
- Activities need to be notified when the state of their control changes.
- Activities should be able to exchange data among themselves.
The Activity lifecycle supports these requirements ☝️

Create and Destroy
- Activity objects are instantiated by the system. To create an Activity, you request it, and the system instantiates it for you. You cannot call the constructor of the Activity yourself; they are under the management of the Android operating system.
- After instantiating these objects, Android will invoke the
onCreate()method. - The
onDestroy()method is invoked to inform the Activity that it is no longer needed. - Despite its name, even after
onDestroy()returns, the actual destruction of the Activity object is not guaranteed.
Start and Stop
onStart()is called when the Activity gains control of any visible area of the screen.onStop()is called when the Activity no longer has control of any visible part of the screen.- ⚠️ Notice that an Activity can be in the background but still has not gone through
onStop()because these two methods discussed earlier are related to the visibility of the screen.⚠️ For example:
1. Activity 1 is in the foreground.
2. Activity 2 comes to the foreground, and Activity 1 goes to the background, but Activity 1 is still visible because Activity 2 is transparent or does not fill the entire screen.
3. Therefore,
onStop()for Activity 1 is NOT called, even though it is in the background.
Resume and Pause
onResume()is called when the Activity becomes interactive to the user (this means when the Activity becomes the top of its respective Activity stack).onPause()is called when the Activity becomes non-interactive to the user (the Activity is not at the top of its respective Activity stack).
Activities Back Stack

- Launch Activity 1:
onCreate(),onStart(),onResume()executed for activity 1. - Launch Activity 2:
onPause()executed for activity 1.onCreate(),onStart(),onResume()executed for activity 2.onStop()executed for activity 1. - Launch Activity 3:
onPause()executed for activity 2.onCreate(),onStart(),onResume()executed for activity 3.onStop()executed for activity 2. - Go back:
onPause(),onStop(),onDestroy()executed for activity 3.onStart(),onResume()executed for activity 2. - Launch Activity 4:
onPause()executed for activity 2.onCreate(),onStart(),onResume()executed for activity 4onStop()executed for activity 2. - Go back:
onPause(),onStop(),onDestroy()executed for activity 4.onStart(),onResume()executed for activity 2. - Go back: On Android 11 and older, activity 1 would be destroyed on back navigation. On Android 12 and newer, it goes to background and can be brought to foreground later.
Android Lifecycle App
🚀 I am building an app to showcase and learn the hole Android lifecycle. Suggestions and contributions are welcome! https://github.com/waleska404/android-lifecycle
👉 Next chapter: Part I I I — Avoid This Mistakes (Activity Lifecycle) 👈 Previous chapter: Part I — Application Process