r

    robnik

    1 year ago
    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.
    Adam Powell

    Adam Powell

    1 year ago
    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

    robnik

    1 year ago
    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
    ?
    Adam Powell

    Adam Powell

    1 year ago
    (navigation that does state save/restore)
    Shakil Karim

    Shakil Karim

    1 year ago
    Actually, I prefer this snippet over Navigation Compose 🙂
    Adam Powell

    Adam Powell

    1 year ago
    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

    robnik

    1 year ago
    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.
    Adam Powell

    Adam Powell

    1 year ago
    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

    robnik

    1 year ago
    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.
    Adam Powell

    Adam Powell

    1 year ago
    kill -9
    from an adb shell should also do it iirc
    Shakil Karim

    Shakil Karim

    1 year ago
    😳 @Adam Powell Is there any example projects you can share where you have disable activity recreation approach?
    Adam Powell

    Adam Powell

    1 year ago
    Not really. Which part are you looking for, just the manifest or something else?