Welcome to the “Saving and Restoring the State of an Android Activity” quiz! This quiz will test your understanding of how to manage dynamic state during activity lifecycle changes, including the use of the Bundle class, methods like onSaveInstanceState() and onRestoreInstanceState(), and the default and manual state-saving mechanisms. By mastering these concepts, you’ll be able to create Android apps that seamlessly handle configuration changes and preserve user experiences.
1.
How can custom objects be made Parcelable for saving in a Bundle?
2.
Why would you use the onRestoreInstanceState() method instead of onCreate() for restoring state?
3.
What happens if the super.onSaveInstanceState() method is not called in the overridden method?
4.
What lifecycle event is triggered before the activity is destroyed during a configuration change?
5.
Why would you disable the automatic state-saving behavior for a view?
6.
Which class is used to store and retrieve dynamic state in Android?
7.
What is the default behavior of most view widgets in saving state during activity recreation?
8.
Which method is called after onSaveInstanceState() when an activity is destroyed due to rotation?
9.
When is onRestoreInstanceState() typically used for state restoration?
10.
What is the purpose of the putCharSequence() method in the Bundle class?
11.
Which method in the Bundle class is used to retrieve text data?
12.
What must an object implement to be stored in a Bundle?
13.
What key-value pair mechanism is used by the Bundle class?
14.
What is a key consideration when naming keys in the Bundle class?
15.
What is the purpose of the onSaveInstanceState() method in Android?
16.
How is state restored in an Android activity?
17.
How can the automatic state-saving behavior of a view widget be disabled?
18.
What is the advantage of using onSaveInstanceState() and onRestoreInstanceState() together?