Complete the code to create a ViewModel instance in an Activity.
val viewModel = ViewModelProvider(this).get([1]::class.java)
You need to pass your ViewModel class to get() to create or retrieve it.
Complete the code to extend the ViewModel class correctly.
class MyViewModel : [1]() { // ViewModel logic here }
Your ViewModel class must extend ViewModel to survive configuration changes.
Fix the error in the code to get the ViewModel in a Fragment.
val viewModel = ViewModelProvider([1]).get(MyViewModel::class.java)
Using requireActivity() shares the ViewModel between Fragment and its Activity, surviving configuration changes.
Fill both blanks to explain why ViewModel survives configuration changes.
ViewModel is stored in the [1] and tied to the [2] lifecycle.
The ViewModelStore keeps ViewModels alive, and they are tied to the Activity lifecycle, which survives configuration changes.
Fill all three blanks to complete the explanation of ViewModel behavior.
When configuration changes, the [1] is destroyed but the [2] and [3] remain, keeping ViewModel alive.
The Activity is destroyed and recreated on configuration change, but the Application and ViewModelStore survive, so ViewModel data is preserved.