Recall & Review
beginner
What is the purpose of saving instance state in Android?
Saving instance state helps preserve UI data and user inputs when the app is temporarily stopped or rotated, so the user doesn't lose their progress.
Click to reveal answer
beginner
Which Android lifecycle method is used to save instance state?
The
onSaveInstanceState() method is called to save data before the activity might be destroyed.Click to reveal answer
beginner
How do you restore saved instance state in an Android activity?
You restore saved data in
onCreate() or onRestoreInstanceState() by reading from the Bundle passed as a parameter.Click to reveal answer
intermediate
What kind of data should you save in the instance state Bundle?
Save small, simple UI-related data like text inputs, scroll positions, or selected items. Avoid saving large or complex objects.
Click to reveal answer
beginner
True or False: The instance state Bundle is saved permanently on the device.
False. The instance state Bundle is temporary and only used to restore UI state during short-term interruptions like rotation or backgrounding.
Click to reveal answer
Which method is called to save UI state before an activity is destroyed?
✗ Incorrect
The onSaveInstanceState() method is specifically designed to save UI state before destruction.
Where do you typically restore saved instance state data?
✗ Incorrect
Saved state is restored in onCreate() or onRestoreInstanceState() using the Bundle parameter.
What type of data is best to save in the instance state Bundle?
✗ Incorrect
Only small, simple UI data should be saved in the Bundle to keep it efficient.
True or False: onSaveInstanceState() is called when the user presses the back button.
✗ Incorrect
onSaveInstanceState() is not called when the user presses back because the activity is finishing.
What happens if you don't save instance state during rotation?
✗ Incorrect
Without saving state, the UI resets and user data is lost on rotation.
Explain how to save and restore UI state in an Android activity during screen rotation.
Think about which methods handle saving and restoring, and what kind of data to save.
You got /5 concepts.
Why is it important to save instance state in mobile apps? Give an example scenario.
Imagine what happens if the user types something and rotates the device.
You got /4 concepts.