Android onStop() not being called when starting a new activity in multi window mode
Asked Answered
C

1

7

I am trying Android N multi window feature and I have found myself confused when starting a new activity. The problem is that when I start a new Activity, the onStop() callback is not being fired and when I press the back button from this new activity to return to the previous one, the previous one's onStart() callback is not being fired either.

Does anyone know what is happening?

--- Edited

It seems like that ActivityOptionsCompat.makeSceneTransitionAnimation has something to do with it.

Cardio answered 8/8, 2016 at 13:12 Comment(2)
if your activity is still visible then onStop() might not be called!Courteous
Thank you for your answer, @himanshu1496. The activity is not visible anymore, the new one takes its place.Cardio
H
8

Here is the android-lifecycle:

AndroidLifecycle

image source

If you call another app in multi window mode, your application is still "partially visible", so onPause() is being called, but onStop() not.

At restart it's the same: onResume() is being called, but onStart() isn't.

Hyehyena answered 8/8, 2016 at 13:15 Comment(5)
Thank you for your answer, @ManuToMatic. Actually, I am not calling another app, but starting a new activity from the same app. Cheers ^^Cardio
How do you start the other activity @AugustoCarmo? With an Intent, as usual?Hyehyena
I am using ActivityOptionsCompat.makeSceneTransitionAnimation. I have shared elements between these two activities.Cardio
I don't know much about shared elements and transition animations, but I think it might have to do with this. Maybe it creates some kind of "link" between the two activities and thus prevents one from being fully stopped but pauses it instead. But I'd have to experiment with this a little bit.Hyehyena
That is what I am thinking too. I am trying to find a solution for this problem. When I disabled the transition feature, everything worked fine.Cardio

© 2022 - 2024 — McMap. All rights reserved.