Android documentation talks about onStop an onDestroy couldn't be called in some circustances, but i didn't find nothing about the same with fragments. Is onPause, onStop, onDestroyView, on Destroy and onDetach always called? Only on Pause?
Asked
Active
Viewed 1.1k times
1 Answers
4
It's the same for Fragments
, so only onPause
is always called.
Most of these callbacks are called at the same time (before or after to be exact) corresponding callbacks from Activity
are called, when the fragment is added via xml layout.
Note that on newer versions of Android onStop
is also always called.
Android documentation talks about onStop an onDestroy couldn't be called in some circustances
Just to make it clear: "some circustances" means your application process being killed by the user or by the system (usually when low on memory or application in background for a longer time).

MaciejGórski
- 22,187
- 7
- 70
- 94
-
Where did you find that "on newer versions of Android onStop is also always called"? Thank you. – Yoann Hercouet May 06 '16 at 11:58
-
If I am not mistaken, onResume and onPause sometimes are not called in fragments. See stackoverflow.com/a/16252923/2914140. But we can force invoking fragment's onResume from an activity, so it will raise every time. – CoolMind Aug 17 '16 at 20:17
-
Starting with Honeycomb, an application is not in the killable state until its onStop() has returned. This impacts when onSaveInstanceState(android.os.Bundle) may be called (it may be safely called after onPause()) and allows an application to safely wait until onStop() to save persistent state. https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle – Valgaal Apr 29 '19 at 16:41