Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing stack including activities in different tasks

I have a main activity A. There are two scenarios

1) A launches B. B has launchmode singleTask and is launched with FLAG_ACTIVITY_NEW_TASK. now I have a menu option in B which performs a delete operation and starts the activity A.

2) A launches B, which launces C it also contains the menu option to perform delet opereation.

I want A to be started with clearing the stack in both the scenarios but the activities belonging to another task still present there I am stuck is there a way to clear the stack.

like image 463
wasaig Avatar asked Nov 13 '22 12:11

wasaig


1 Answers

try using following code on delete opereation on both B and C activity

    Intent intent=new Intent(B.this, A.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
like image 81
jeet Avatar answered Nov 16 '22 02:11

jeet