I know for an Activity onDestroy(...)
is not guaranteed to be called. According to the docs,
There are situations where the system will s
I believe that Fragment's onDestroy()
is not guaranteed to be called just as Activity's.
In Activity's performDestroy()
:
final void performDestroy() {
mDestroyed = true;
mWindow.destroy();
mFragments.dispatchDestroy();
onDestroy();
if (mLoaderManager != null) {
mLoaderManager.doDestroy();
}
}
where mFragments.dispatchDestroy()
will finally call fragments onDestroy()
, if you digg into the source. So, if Activity's onDestroy()
not called, fragment's onDestroy()
won't be called.
And there's some other links:
fragment lifecycle: when "ondestroy" and "ondestroyview" are not called?
Android fragments lifecycle onStop, onDestroyView, onDestroy and onDetach