简体   繁体   English

从backStack删除活动

[英]Removing Activities from backStack

I have six activities. 我有六个活动。 Lets say A,B,C,D,E,P 假设A,B,C,D,E,P

I want to create these flows 我想创建这些流程

1) A --> B --> C --> D --> E Move Back A <-- B <-- C <-- D <-- E (DONE) 1)A-> B-> C-> D-> E返回A <-B <-C <-D <-E (完成)

2) A --> B --> C --> D --> P 2)A-> B-> C-> D-> P

P have two button Yes and No P有两个按钮,

if Yes A <-- P (Removing D,C,B From backstack) 如果是,则 A <-P (从后堆栈中删除D,C,B)

if No B <-- P (Removing D,C From backstack) 如果没有 B <-P(从后堆栈中删除D,C)

3) A --> B --> C --> D --> E --> P 3)A-> B-> C-> D-> E-> P

P have two button Yes and No P有两个按钮,

if Yes A <-- P (Removing E,D,C,B From backstack) 如果是,则A <-P(从后堆栈中删除E,D,C,B)

if No B <-- P (Removing E,D,C From backstack) 如果没有B <-P(从后堆栈中删除E,D,C)

You should use FLAG_ACTIVITY_CLEAR_TOP flag to your intent. 您应根据自己的意图使用FLAG_ACTIVITY_CLEAR_TOP标志。 Also I recommend you to learn all intent flags. 另外,我建议您学习所有意图标志。 Probably you also should set launchMode for your activites A and B in AndroidManifest.xml to singleTask 也许您还应该将launchMode中的活动A和B的launchMode设置为singleTask

Check this out ...here is all the information you may need to learn about moving between activities 看看...这里是您可能需要了解的关于在活动之间进行转移的所有信息

enter link description here : https://developer.android.com/guide/components/activities/tasks-and-back-stack.html#Clearing 在此处输入链接描述https : //developer.android.com/guide/components/activities/tasks-and-back-stack.html#Clearing

YourCurrentActivity.this.finish();  
     Intent intent1 = new Intent(YourCurrentActivity.this,LoginActivity.class);  
     intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);   
     startActivity(intent1); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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