Recall & Review
beginner
What is the Android Activity lifecycle?
The Android Activity lifecycle is a set of states an Activity goes through from creation to destruction, such as onCreate, onStart, onResume, onPause, onStop, and onDestroy.
Click to reveal answer
beginner
Why can ignoring lifecycle methods cause bugs?
Ignoring lifecycle methods can cause bugs like memory leaks, crashes, or unexpected behavior because the app might try to use resources that are not available or not properly released.
Click to reveal answer
intermediate
What happens if you update UI after onPause()?
Updating UI after onPause() can cause crashes or inconsistent UI because the Activity might not be visible or ready to show changes.
Click to reveal answer
intermediate
How does understanding lifecycle help manage resources?
It helps by knowing when to start or stop tasks like animations, network calls, or sensors to avoid wasting battery or causing errors.
Click to reveal answer
beginner
What lifecycle method is best to save user data before the app closes?
onSaveInstanceState() is best to save user data before the app closes or the Activity is destroyed, ensuring data is not lost.
Click to reveal answer
Which lifecycle method is called when an Activity becomes visible to the user?
✗ Incorrect
onStart() is called when the Activity becomes visible but not yet in the foreground.
What can happen if you don’t release resources in onStop()?
✗ Incorrect
Not releasing resources can cause memory leaks, slowing down or crashing the app.
When should you save user data to avoid loss during configuration changes?
✗ Incorrect
onSaveInstanceState() is designed to save data before the Activity is destroyed or recreated.
Which lifecycle method is called just before the Activity is destroyed?
✗ Incorrect
onDestroy() is called before the Activity is completely removed from memory.
Why is it important to understand lifecycle when working with background tasks?
✗ Incorrect
Understanding lifecycle helps manage background tasks properly to avoid waste and errors.
Explain how the Android Activity lifecycle helps prevent bugs in an app.
Think about what happens when the app moves between visible and hidden states.
You got /4 concepts.
Describe common bugs caused by ignoring lifecycle methods and how to avoid them.
Consider what happens if you keep using resources after the Activity is stopped.
You got /4 concepts.