Android remove Activity from back stack

后端 未结 11 2083
予麋鹿
予麋鹿 2020-12-07 17:23

Okay so I\'m kind of stumped on what to do with this. So I have the MainActivity, and from there an Activity can be launched to DegreePlanActivity, and from there another Ac

11条回答
  •  难免孤独
    2020-12-07 18:04

    FLAG_ACTIVITY_CLEAR_TOP clears your Activity stack , you can use the code below:

    Intent intent = new Intent(this, Activity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    

    Remember that this flag clears just Intermediate Activities , for example if you have A,B,C in your Back Stack then going from C Activity to D with this flag this does not clear Back Stack and the Stack would be A,B,C,D but if you go from Activity D to Activity A with this flag , B,C,D Activities will pop up from the stack and you will have just A in the Back Stack .

提交回复
热议问题