Do I need to set up some kind of registry for `rem...
# compose
r
Do I need to set up some kind of registry for
rememberSaveable
to work? I stopped using the standard `NavController`/`NavHost` and now it (and
rememberLazyListState
) stopped working.
a
If you have your own navigation system then yes, otherwise when rememberSaveable leaves the composition it's just gone.
(Presumably for a navigation operation that didn't save the data)
r
Okay, I have used various
Local__
values, but not provided one yet. Is that what I need to do? Define something to attach to
LocalSaveableStateRegistry
?
a
🙏 1
👍 2
(navigation that does state save/restore)
s
Actually, I prefer this snippet over Navigation Compose 🙂
😅 1
a
note that deep link handling isn't there; I haven't had cause to add it for my apps yet. Nor is AAC ViewModel scoping for similar reasons; I use this in apps that disable activity recreation for config changes so I don't use AAC ViewModel at all.
r
I guess I’m confused about what
rememberSaveable
is normally supposed to do. The function’s comment doc says it “will survive the activity or process recreation”. By ‘process’, does it meant killing and restarting the app? That does not work for the simple test I just ran.
a
how did you kill and restart it for your test? There are lots of ways that take a very different code path that will not retain the state.
swiping away from the phone's overview screen, for example, force stop, the red stop button in android studio...
r
I tried swiping away, and stop and re-run from Studio. I just tried the "don't keep activities" developer option, and with that I can now see a difference between remember and rememberSaveable.
a
kill -9
from an adb shell should also do it iirc
s
😳 @Adam Powell Is there any example projects you can share where you have disable activity recreation approach?
a
Not really. Which part are you looking for, just the manifest or something else?