Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android fragments lifecycle onStop, onDestroyView, onDestroy and onDetach

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?

like image 869
juan Avatar asked Oct 03 '22 18:10

juan


1 Answers

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).

like image 166
MaciejGórski Avatar answered Oct 10 '22 17:10

MaciejGórski