Closed progk closed 3 years ago
You could have problems if for example your presenter will call method which shows fragment using FragmentTransaction#commit()
or FragmentTransaction#commitNow()
. If you did not detach your MvpDelegate
during onSavedInstanceState
this method could get called after saving state which will lead to a app crash.
Detach is also called in MvpAppCompatFragment.onStop. Should work fine in your case
From the documentation (https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle)):
If called, this method will occur after onStop() for applications targeting platforms starting with Build.VERSION_CODES.P. For applications targeting earlier platform versions this method will occur before onStop() and there are no guarantees about whether it will occur before or after onPause().
Ok, i got it, thanks for explanation
Hi! I have various presenter behaviour on different Android versions because of
MvpDelegate.onDetach
call inMvpAppCompatFragment.onSaveInstanceState
MvpAppCompatFragment
lifecycle callbacks after request permission:Android 6 (API 23): …
onResume
(request permission)onPause
onSavedInstanceState
…Android 10 (API 29): …
onResume
(request permission)onPause
…In my app i use custom
MvpFragment
(with the same logic) and plan to removeonDetach
fromonSaveInstanceState
. I see no reason not to do it. Could you explain please why this logic was added or provide cases of possible memory leaks?