-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserving State #38
Comments
@rpuxa-copilot For saving a state of a composable function you should use 'rememberSaveable' https://developer.android.com/develop/ui/compose/state#restore-ui-state For saving a state of a ViewModel use 'SavedStateHandle' https://developer.android.com/topic/libraries/architecture/viewmodel/viewmodel-savedstate The library fully supports this functionality and doesn't change the already existing API in any way. |
I think you completely misunderstood my question. I don't need to save the state during activity or process death. I need to save state when I go to another screen and back. Here is the simplest example I can provide.
If I click Next and than Prev, the first WebView gets reloaded. This happens because when I go from screen 1 to screen 2, the first WebView gets discarded. This also happens to remember functions and ViewModels. If I used Fragments or Activities, I wouldn't get this problem |
I am sorry, you where right about |
How can I achieve the same state preservation in this library as I had with a stack of activities? When I open a new activity on top of another, the state of the underlying activity is preserved, including all Views and ViewModels. However, when trying to replicate this behavior with AnimatedHost in Jetpack Compose, the state of the previous screen is lost. This includes the state managed by remember, AndroidView, and ViewModel. What can I do to ensure that the state of the previous screen is retained when navigating between screens using AnimatedHost?
The text was updated successfully, but these errors were encountered: