Vasiliy Vasiliy - 10 months ago 53
Android Question

Activity's onStop() not called when starting another full screen Activity

I used to think that when Activity A is being replaced with another full-screen Activity B, then A's

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.

enter image description here

Now, however, I'm observing a different behavior (tested on Lollipop and Marshmallow).

I start
and, despite the fact that
is a full-screen activity,
is not stopped.

Declaration of these activities in manifest:

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>


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?

Answer Source

"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