October 2019
Intermediate to advanced
624 pages
20h 7m
English
While saved instance state stores an activity record across process death, it also stores an activity record across a configuration change. When you first launch the activity, the saved instance state bundle is null. When you rotate the device, the OS calls onSaveInstanceState(Bundle) on your activity. The OS then passes the data you stashed in the bundle to onCreate(Bundle?).
If saved instance state protects from both configuration changes and process death, why bother with a ViewModel at all? To be fair, GeoQuiz is so simple that you could have gotten away with saved instance state only.
However, most apps do not rely on a small, hardcoded question bank data set like GeoQuiz does. Most apps ...
Read now
Unlock full access