0
0
Android Kotlinmobile~10 mins

Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy) in Android Kotlin - UI Render Trace

Choose your learning style9 modes available
Component - Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy)

This component shows the Android Activity lifecycle methods. These methods run at different times as the app screen (Activity) opens, becomes visible, gains focus, loses focus, stops, or is destroyed. They help manage what the app does during these changes.

Widget Tree
ActivityLifecycleDemo
├── onCreate()
├── onStart()
├── onResume()
├── onPause()
├── onStop()
└── onDestroy()
The ActivityLifecycleDemo is the main screen. It has six lifecycle methods as its key parts. Each method runs in order as the Activity moves through states: creation, becoming visible, gaining focus, losing focus, stopping, and destruction.
Render Trace - 6 Steps
Step 1: ActivityLifecycleDemo
Step 2: ActivityLifecycleDemo
Step 3: ActivityLifecycleDemo
Step 4: ActivityLifecycleDemo
Step 5: ActivityLifecycleDemo
Step 6: ActivityLifecycleDemo
State Change - Re-render
Trigger:User presses home button or switches to another app
Before
Activity is running and visible (onResume state)
After
Activity moves to background (onPause then onStop called)
Re-renders:The Activity lifecycle methods onPause and onStop run; UI is no longer visible.
UI Quiz - 3 Questions
Test your understanding
Which lifecycle method runs first when the Activity is created?
AonResume
BonCreate
ConStart
DonDestroy
Key Insight
Understanding Activity lifecycle methods helps you manage app behavior during screen changes. For example, you save data in onPause or onStop and release resources in onDestroy. This keeps your app smooth and efficient.