I used to think that when Activity A is being replaced with another full-screen Activity B, then A's onStop()
callback will be invoked.
This is also reflected in docs:
The visible lifetime of an activity happens between the call to onStart() and the call to onStop(). During this time, the user can see the activity on-screen and interact with it. For example, onStop() is called when a new activity starts and this one is no longer visible.
Now, however, I'm observing a different behavior (tested on Lollipop and Marshmallow).
I start AuthenticationActivity
from HomeActivity
and, despite the fact that AuthenticationActivity
is a full-screen activity, HomeActivity
is not stopped.
Declaration of these activities in manifest:
<activity
android:name=".screens.home.activities.HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".screens.authentication.activities.AuthenticationActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme.Transparent"/>
When activities switch, this is what I observe in logcat:
11-28 10:16:31.443 15183-15183/somepackage I/LOG:: LifeCycle : activity (somepackage.screens.home.activities.HomeActivity@3561e8e1) paused
11-28 10:16:31.583 15183-15183/somepackage I/LOG:: LifeCycle : activity (somepackage.screens.authentication.activities.AuthenticationActivity@2bbdb20f) created
11-28 10:16:31.753 15183-15183/somepackage D/Activity: performCreate Call secproduct feature valuefalse
11-28 10:16:31.753 15183-15183/somepackage D/Activity: performCreate Call debug elastic valuetrue
11-28 10:16:31.753 15183-15183/somepackage D/AuthenticationActivity: onStart()
11-28 10:16:31.753 15183-15183/somepackage I/LOG:: LifeCycle : activity (somepackage.screens.authentication.activities.AuthenticationActivity@2bbdb20f) started
11-28 10:16:31.993 15183-15183/somepackage D/AuthenticationActivity: onResume()
11-28 10:16:31.993 15183-15183/somepackage I/LOG:: LifeCycle : activity (somepackage.screens.authentication.activities.AuthenticationActivity@2bbdb20f) resumed
11-28 10:16:32.213 15183-15183/somepackage I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@266569db time:354918367
11-28 10:16:32.613 15183-15183/somepackage I/LOG:: LifeCycle : activity (somepackage.screens.home.activities.HomeActivity@3561e8e1) saveInstanceState
11-28 10:16:32.633 15183-15183/somepackage V/ActivityThread: updateVisibility : ActivityRecord{2bcd65fd token=android.os.BinderProxy@86da390 {somepackage/somepackage.screens.home.activities.HomeActivity}} show : true
What's going on?
"For example, onStop() is called when a new activity starts and this one is no longer visible."
Because your AuthenticationActivity is transparent, HomeActivity is still visible => onStop isn't called