简体   繁体   中英

How to manipulate current task's Activity back stack?

Currently I have 3 Activity classes A, B and C.

Activity A is a singleTask while other has the default launch mode. Consider a case: the user is first in A, then starts B, and then starts C.

The back stack now is ABC.

Next, the user starts A again.

The back stack now is A, but what I would like to be achieved is ABCA.

I know not setting Activity A to be singleTask can have a back stack : ABCA. But I really need the Activity A to be the same instance.

Anyone know how to do this?

You have stipulated two conditions:

what I would like to be achieved is ABCA.

and

I really need the Activity A to be the same instance.

These two conditions are mutually contradictory. Absolutely.

What you want is impossible.

That is all.

That is not possible.

if you want to open existing activity then

launch your activity as

    Intent intent = new Intent(this, YourActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);

Are you sure you need singleTask and not singleTop ? Could you describe why do you need it singleTask ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM