rememberSaveableStateHolder() will return a SaveabelStateRegistry which is restricted to store only types that can be saved as Bundle.
Is there an alternative without restriction?
I do not need persistence storage in my navigation solution.
02/14/2021, 3:50 PM
Bundles are not persistence; they are not saved to disk at all. However, if you want to survive process death and recreation, your type must be able to be stored in a Bundle. Otherwise you could just use
02/14/2021, 6:12 PM
do you mean you don’t want to restore state when activity is recreated? and why don’t you need it?
02/14/2021, 8:21 PM
In compose usually i do have only one activity which do handly configuration changes without recreation. So it is not necessary. There is no need to introduce more complexity than necessary.
Also i still can save my navigation states outside of the activity
02/14/2021, 8:25 PM
the saved instance state mechanism can be triggered not only when the screen is rotated, but also when the system decides to kill the process to give the freed ram to the other process. for example it usually happens when the camera app is opened which requires a lot of memory. in this case when user goes back to your app the state would be restored. also note that SaveableStateHolder saves not the navigation state, but the inner states of the screens in the back stack.
02/14/2021, 8:45 PM
Testing with the "Don't keep activities" option on is a good litmus test, but keep in mind that Android kills your whole process (unlike what don't keep activities does), so stashing something else in memory outside of the Activity still isn't a fix