Skip to content Skip to sidebar Skip to footer

Android Viewmodel Savedstatehandle

This is more of a conceptual question. Android recently introduced the concept of handling the state during process death inside viewModel rather than savedInstanceState which pre

Solution 1:

enter image description here

  1. Enable `Don't keep activities'
  2. Launch your app
  3. Tap the home button
  4. Your app will be killed immediately (Activity.onDestroy called)

Solution 2:

Below Steps helps in testing the intelligence of View Model Saved State Library

Step1: After completing the source code changes, build and run the APP.
Step2: Ensure UI of Activity/Fragment has data populated in it.
Step3: Move the App to background by clicking Home Button.
Step4: Now Open the Logcat Tool window and Terminate the APP.
Step5: Relaunch the APP from the Device or Emulator.
Step6: You should see all the data pre-populated in UI.

Post a Comment for "Android Viewmodel Savedstatehandle"