tezvyn:

How does a ViewModel survive configuration changes?

Source: developer.android.comintermediate

Tests understanding of ViewModel's scope, separate from the Activity lifecycle. A ViewModel is retained by a ViewModelStore, which persists across configuration changes. The new Activity instance then reconnects to the same ViewModel.

This tests your grasp of how ViewModel is scoped and retained across configuration changes, separating it from the volatile Activity lifecycle. A great answer explains that a ViewModelStore holds the ViewModel instance. This store is a retained non-configuration object that survives Activity recreation. The new Activity instance then reconnects to this store. A common red flag is confusing ViewModel's in-memory retention with onSaveInstanceState, which handles process death by saving data to a Bundle.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

How does a ViewModel survive configuration changes? · Tezvyn