Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 previously used to be in Activity or Fragment.

My question is how do I test this process death? If I rightly understand the documentation, the Process death happens to be Android killing the app due to full memory when app is no longer used in background.

Also will the viewModel save the state when user kills the app from the RAM? So that I can retrieve the state as the user opens the app again.

like image 678
Ma2340 Avatar asked Oct 12 '25 13:10

Ma2340


1 Answers

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)
like image 160
CHAN Avatar answered Oct 14 '25 02:10

CHAN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!