Challenge - 5 Problems
Lifecycle Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2: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?
Attempts:
2 left
💡 Hint
Think about the method that makes the activity visible but not yet ready for user interaction.
✗ Incorrect
The onStart() method is called when the activity becomes visible to the user but is not yet in the foreground for interaction. onCreate() is for initial setup, onResume() is when the activity is interactive, and onPause() is when it loses focus.
❓ ui_behavior
intermediate2: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?
Attempts:
2 left
💡 Hint
This method is called after the activity is no longer visible but before it is destroyed.
✗ Incorrect
onStop() is called when the activity is no longer visible to the user. onPause() is called when the activity loses focus but might still be partially visible.
❓ lifecycle
advanced2: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?
Attempts:
2 left
💡 Hint
Remember the lifecycle starts with onCreate, then onStart, then onResume when the activity is interactive.
✗ Incorrect
The correct lifecycle order when launching is onCreate(), onStart(), onResume(). When the home button is pressed, onPause() is called first, then onStop().
🔧 Debug
advanced2: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?
Attempts:
2 left
💡 Hint
Think about whether the UI is visible and interactive during onStop().
✗ Incorrect
During onStop(), the activity is no longer visible, so UI updates do not show on screen but do not cause exceptions. IllegalStateException or NullPointerException do not occur just by updating UI here.
🧠 Conceptual
expert2: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?
Attempts:
2 left
💡 Hint
Consider the lifecycle method that is called first when the activity is about to go away.
✗ Incorrect
onPause() is always called before onStop() and onDestroy(). onDestroy() is the last method but not guaranteed to be called in all cases. onSaveInstanceState() is optional and not always called.