Introduction
When building Android applications, one of the most foundational concepts every developer must understand is the Activity Lifecycle. An Android app is composed of multiple activities—essentially the screens that users interact with. Each activity transitions through different states such as created, started, resumed, paused, stopped, and destroyed. Understanding these states is critical for creating apps that are efficient, responsive, and bug-free.
For both beginners and seasoned developers, mastering the activity lifecycle is a stepping stone toward writing robust, high-performance Android apps. At CuriosityTech.in, our courses emphasize this concept, integrating real-world examples and hands-on practice to help learners solidify their understanding.
Main Content
What is an Activity in Android?

Understanding the Activity Lifecycle
The activity lifecycle consists of callbacks triggered by the Android system to indicate changes in activity state. These states are:
- onCreate()
- Called when the activity is first created.
- Initialize UI components, set up bindings, and prepare resources.
- Called when the activity is first created.
Example:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
- onStart()
- Activity is becoming visible to the user.
- Ideal for initializing components that refresh the UI.
- Activity is becoming visible to the user.
- onResume()
- Activity is at the foreground and the user can interact with it.
- Resume animations, video playback, or sensor updates.
- Activity is at the foreground and the user can interact with it.
- onPause()
- Called when another activity comes in the foreground.
- Save user data, stop animations, or release heavy resources to reduce memory usage.
- Called when another activity comes in the foreground.
- onStop()
- Activity is no longer visible.
- Release resources or commit unsaved changes.
- Activity is no longer visible.
- onDestroy()
- Activity is being destroyed.
- Final cleanup such as removing observers, closing database connections.
- Activity is being destroyed.
- onRestart()
- Called when an activity moves from stopped to started state.
- Useful for refreshing UI elements without full recreation.
- Called when an activity moves from stopped to started state.
Lifecycle Diagram
Here’s a hierarchical diagram illustrating transitions between states:
onCreate()
|
onStart()
|
onResume()
|
—————–
| |
onPause() onStop()
| |
onResume() onRestart()
| |
onStop() ———–
|
onDestroy()
Practical Example
Imagine you are building a music player app. You want music playback to pause when the user navigates to another app and resume when they return:
override fun onPause() {
super.onPause()
mediaPlayer.pause() // Pause music
}
override fun onResume() {
super.onResume()
mediaPlayer.start() // Resume music
}
By managing resources in lifecycle methods, your app conserves battery, prevents crashes, and ensures a smooth user experience.

Conclusion
Understanding the Android Activity Lifecycle is essential for building stable, performant, and user-friendly applications. By mastering the lifecycle, developers can ensure seamless user experiences, efficient resource management, and better app stability. Whether you’re developing simple apps or complex cross-platform solutions, integrating lifecycle management early in your development process is crucial.
At CuriosityTech.in, we provide step-by-step guidance and practical exercises that help learners grasp these concepts intuitively, preparing them for real-world app development.