Android fragments lifecycle onStop, onDestroyView,

2019-05-07 18:00发布

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?

1条回答
做自己的国王
2楼-- · 2019-05-07 18:52

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

查看更多
登录 后发表回答