2

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.

xyals
  • 347
  • 1
  • 2
  • 9
  • I think while using Alert Dialog, when alert dialog is called fragment will go to onPause() and when alert dialog is closed it'll call onResume() – Yatish Feb 13 '18 at 05:32
  • I believe using split screen would also do this. – xyals Feb 23 '18 at 21:18

1 Answers1

3

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.

Hendrik Marx
  • 709
  • 4
  • 9