The onDispose
callback isn't called when i close my app or when its process is killed. Is this intended behavior? Is there a different callback for this event? Can I make my own, by somehow passing MainActivity
s onStop
callback down to a composable?
The reason I need this sort of callback is because I want to save some data, that the user entered, to the database when the user leaves the screen or on process death. I learned that SavedStateHandle
is made for this use case, but only for small amounts of data - I want to save complex, non-parcelable data and I don't want the code overhead that SavedStateHandle
seems to have.
My current workaround is to save to the database on every change, which isn't hard since my code is reactive using coroutine StateFlow
. I fear that this has performance implications, but maybe I'm wrong and this is the best solution.