https://kotlinlang.org logo
#compose
Title
# compose
s

Stylianos Gakis

01/07/2022, 6:17 AM
Is there a way to remember things across configuration changes without AAC VM? My specific use case is that I am using a MediaPlayer inside a class that I am now `remember`ing that I would like to persist when the user selects dark mode for example. But putting that inside a rememberSaveable seems a bit tricky, since I can’t persist its internal state because rememberSaveable will try to re-create it even after process death. Is ViewModel my only solution here for this use case of “persist it across config changes, but not across process death”?
a

allan.conda

01/07/2022, 7:22 AM
You can override config changes completely if you're doing a compose first Activity
s

Stylianos Gakis

01/07/2022, 8:06 AM
Is that specified somewhere in the documentation on how to do this properly?
a

allan.conda

01/07/2022, 8:07 AM
It's somewhere here in slack 😁. Not in official docs yet I believe. I might be outdated
s

Stylianos Gakis

01/07/2022, 8:12 AM
Very interesting yeah, my app is definitely not all compose, but it can happen on a per-activity basis so that’s something I need to test. And for activities that are mixed, I guess AAC VM actually seems to be the only proper answer.
a

allan.conda

01/07/2022, 8:32 AM
What's a mixed activity? If it's compose first, the views are wrapped so I think you can still use it.
s

Stylianos Gakis

01/07/2022, 8:46 AM
I was referring to the opposite situation, a View-based activity with some ComposeViews here and there, for example inside RecyclerViews.
a

allan.conda

01/07/2022, 9:28 AM
Ah. Yes, in that case
🙏 1