When will onResume() be called without onStart() being called first (Fragment Lifecycle)

蹲街弑〆低调 提交于 2020-01-04 05:20:51

问题


onStart() is when the Fragment becomes visible, onResume() is when the Fragment becomes interactive. So when will the onResume() -> onPause() -> onResume() cycle execute without executing the encompassing onStart() -> onStop() cycle?

In terms of fragment transitions, a replace will destroy the starting fragment, calling its onPause() -> onStop() as well as other destroy related life-cycle methods. If the transition is replace but add the starting fragment to **backStack**, it will still call onPause() -> onStop() except without completely destroying the fragment and detaching it from activity. In the case of just overlaying another fragment, none of the starting fragment's lifecycle events are executed because its still there just not visible (another fragment getting drawn over it).

I'm not sure when onResume() will ever be called without onStart(), as well as onPause() with onStop().

Edit: Along with the answers already here, using android split screen would also pause the fragment without stopping it.


回答1:


When your activity stays visible while showing a dialog or another activity is shown on top that has transparency.

Basically your activity is visible between onStart()and onStop() and your activity is interactive between onResume() and onPause(). When it it becomes uninteractive while staying visible you will get onPause without onStop.



来源:https://stackoverflow.com/questions/48760014/when-will-onresume-be-called-without-onstart-being-called-first-fragment-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!