0

So, my app has 5 activities: A, B, C, D, E. A is the splash (launcher) activity and never gets called again after launch. After launching, B gets called and serves as the Home activity. B, C, D, E all get called with Intent.FLAG_ACTIVITY_REORDER_TO_FRONT so that one instance is reused and updated through onNewIntent(). It works. I'm happy with the user experience.

Here's my question. I would like the first instance of B (upon launch) to hold as the root task. In other words, I would like this first instance of B to be the last screen the user sees if pressing the back button continually until exiting the app. All other of instances of B should be "recycled" normally using the Intent.FLAG_ACTIVITY_REORDER_TO_FRONT.

I'm pretty certain I can make a unique activity (call it B2) and accomplish this, is there a better way?

seekingStillness
  • 4,833
  • 5
  • 38
  • 68
  • I think, you have to start all other activity except the B with using the Intent.FLAG_ACTIVITY_REORDER_TO_FRONT. please check "https://android.jlelse.eu/android-activity-launch-mode-e0df1aa72242" – TejaDroid Mar 09 '18 at 12:59

1 Answers1

0

You can use

Intent cActivity = new Intent(BActivity.this,CActivity.class);
cActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(cActivity);

setting Intent.FLAG_ACTIVITY_NEW_TASK will hold your B Activity's instance and open your Activity C as new task. or you can call startActivity() without setting any flag.

Chintak Patel
  • 748
  • 6
  • 24