Sunday, 9 June 2019

Android activity not started if already in the backstack as the root?

I have a sample app with 3 activities: Main, A and B. None of them has any launchMode.

Now I do this:

  1. open the app, Main activity is displayed
  2. leave the app using back button, so that there is no activity running
  3. receive a broadcast which starts a new activity A (new_task flag)
  4. open activity B by clicking on a button in activity A (no flags)
  5. receive a broadcast which starts a new activity A (new_task flag)
  6. new activity A is not started (if I go back, there's still the previous Activity A)

At step #6, activity A should be presented but is not.

If I try to present activity C instead (in #5), it is presented as expected.

If in #2 I leave the app by homebutton instead, everything works as expected.

How is this possible? And how can I ensure that the activity is always presented? I could use FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP, but I want to maintain the backstack.



from Android activity not started if already in the backstack as the root?

No comments:

Post a Comment