简体   繁体   中英

Removing Activities from backStack

I have six activities. Lets say 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)

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

P have two button Yes and No

if Yes A <-- P (Removing D,C,B From backstack)

if No B <-- P (Removing D,C From backstack)

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

P have two button Yes and No

if Yes A <-- P (Removing E,D,C,B From backstack)

if No B <-- P (Removing E,D,C From backstack)

You should use FLAG_ACTIVITY_CLEAR_TOP flag to your intent. 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

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

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

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