Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is onStop() always called once onPause() is called

Tags:

android

Is it possible that onPause() is called, and then immediately after that, onResume() is called? In other words, does the activity always has to go through onStop(), onStart() and then onResume() after its onPause() is called?

The activity lifecycle document says it is possible, but what would be the user actions to trigger that? Can anyone create an activity JUnit test to demonstrate that?

like image 894
dacongy Avatar asked Dec 09 '25 21:12

dacongy


2 Answers

If Activity hasn't been fully obscured by another Activity then onStop won't be called

like image 94
Alexander Kulyakhtin Avatar answered Dec 12 '25 13:12

Alexander Kulyakhtin


Yes, it is common for onPause() -> onResume() -> onPause() -> onResume() cycle to occur.

See the Activity lifecycle docs.

If an Activity is totally obscured (by another Activity for example) it will likely be stopped but if it is only partly obscured by another Activity (set with a dialog theme, for example), then it will simply be paused and then resumed when the 'popup' Activity is closed.

like image 30
Squonk Avatar answered Dec 12 '25 14:12

Squonk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!