0
0
Android Kotlinmobile~20 mins

Activity lifecycle methods (onCreate, onStart, onResume, onPause, onStop, onDestroy) in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Lifecycle Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
Which lifecycle method is called when the activity becomes visible to the user?
An Android activity goes through several lifecycle stages. When the activity is about to become visible but not yet interactive, which method is called?
AonStart()
BonResume()
ConPause()
DonCreate()
Attempts:
2 left
💡 Hint
Think about the method that makes the activity visible but not yet ready for user interaction.
ui_behavior
intermediate
2:00remaining
What lifecycle method is called when the activity is no longer visible?
When an activity moves out of the screen and is no longer visible to the user, which lifecycle method is called?
AonStop()
BonPause()
ConDestroy()
DonResume()
Attempts:
2 left
💡 Hint
This method is called after the activity is no longer visible but before it is destroyed.
lifecycle
advanced
2:00remaining
What is the correct order of lifecycle method calls when an activity is launched and then the user presses the home button?
Consider the sequence of lifecycle methods called when an activity starts and then the user presses the home button to send the app to the background. Which option shows the correct order?
AonCreate() → onStart() → onPause() → onResume() → onStop()
BonCreate() → onResume() → onStart() → onPause() → onStop()
ConStart() → onCreate() → onResume() → onPause() → onStop()
DonCreate() → onStart() → onResume() → onPause() → onStop()
Attempts:
2 left
💡 Hint
Remember the lifecycle starts with onCreate, then onStart, then onResume when the activity is interactive.
🔧 Debug
advanced
2:00remaining
What error occurs if you try to update UI elements in onStop()?
In Android, if you try to update UI elements (like TextView) inside the onStop() method, what kind of problem or error will most likely happen?
ANo error, UI updates work normally
BIllegalStateException because UI is not visible
CUI updates are ignored silently without error
DNullPointerException because views are destroyed
Attempts:
2 left
💡 Hint
Think about whether the UI is visible and interactive during onStop().
🧠 Conceptual
expert
2:00remaining
Which lifecycle method is guaranteed to be called before the activity is destroyed?
When an Android activity is finishing or being destroyed by the system, which lifecycle method is always called before the activity is destroyed?
AonStop()
BonPause()
ConDestroy()
DonSaveInstanceState()
Attempts:
2 left
💡 Hint
Consider the lifecycle method that is called first when the activity is about to go away.