B-> C-> D-> E and there ...">

Android How can I "jump to another branch" in the "Back back" "Activity" tree?

Let's say I have a stack like this: A-> B-> C-> D-> E and there is an action in E that appears E, D, C and starts F, so I get A → B-> F.

How can I build such a back stack? Can I use startActivity B with FLAG_ACTIVITY_CLEAR_TOP followed by startActivity F? Wouldn't the first startActivity function close E before it could add F? How could I, for example, have A-> B-> C and change the action in C to A-> D-> E? Can I use PendingIntent with TaskStackBuilder for this?

Thanks in advance! (By the way, this is my first question!)

+4
source share
1 answer

To clear the stack before Band then run F, follow these steps:

Intent intent = new Intent(this, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("startF", true);
startActivity(intent);

In B.onNewIntent()do the following:

if (intent.hasExtra("startF") {
    Intent startF = new Intent(this, F.class);
    startActivity(startF);
}

You can use this concept everywhere to return to the stack for a specific Activity, and tell this Office which new activity to launch.

0
source

All Articles