How can I exactly match the activity/fragment lifecycle callbacks? I'm
normally having a great time with DisposableEffect and friends, but for
integrating with mapbox sdk I need to call their code on onStart,
onStop, onLowMemory, and onDestroy. I've already made a
LocalActivity
to use with some legacy stuff, so I'm thinking of making it a
LocalMySpecificActivity
and adding methods like
registerOnDestroy
to it. Is there a better solution?
i
Ian Lake
06/21/2021, 3:18 AM
Have you looked at
LocalLifecycleOwner
? Adding an observer on that within a
DisposableEffect
(that would remove the observer on disposal) would give you all of the lifecycle callbacks at least
d
Daniel
06/21/2021, 3:19 AM
That looks nearly perfect. I don't handle low memory anywhere else, so I think I'll just ignore that.