22. Saving and Restoring the State of an Android Activity

If the previous few chapters have achieved their objective, it should now be a little clearer as to the importance of saving and restoring the state of a user interface at particular points in the lifetime of an activity.

In this chapter, we will extend the example application created in “Android Activity State Changes by Example” to demonstrate the steps involved in saving and restoring state when an activity is destroyed and recreated by the runtime system.

A key component of saving and restoring dynamic state involves the use of the Android SDK Bundle class, a topic that will also be covered in this chapter.

22.1 Saving Dynamic State

An activity, as we have already learned, is given ...

Get Android Studio 3.6 Development Essentials - Kotlin Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.