Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
For the More Curious: Activity and Instance State
SavedStateHandle is an easy-to-use API that allows you to safely store and retrieve instance state and persist that information even if your process is killed. But it has not always been around. Before SavedStateHandle was released in 2020, developers were expected to use APIs within Activity.
To store instance state, developers used the Activity.onSaveInstanceState(Bundle) function. Similar to Activity.onPause() and Activity.onStop(), Activity.onSaveInstanceState(Bundle) is like a lifecycle callback called during the teardown of an activity. To retrieve instance state, developers used an API you are already familiar with: Activity.onCreate(Bundle?). The Bundle? passed in as a parameter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access