0

Possible Duplicate:
Removing an activity from the history stack

I've 1 question for the Android stack and the push stack process as stated below:

A->B->C->C->C->C->D

C will be repeatedly call itself until certain condition met.

i use the code below to start activity.

Intent intent = new Intent(this, MyActivity.class); startActivity(intent);

My problem is after activity D started i want straight away go back to activity B instead of go back activity C when press the back button.

A->B->C->C->C->C->D -----> A->B

I know i should use intent setFlags but i've no idea what to use http://blog.akquinet.de/2010/04/15/android-activites-and-tasks-series-intent-flags/

Any suggestion?

Thanks in advance.

Edited: For this case Activity C is question page and the Activity D is the result page. A->B->Question 1->Question 2-> Question 3 -> Result.

I need to keep the history stack b4 activity D, this will allowed user to change the answer.

0

3 Answers 3

1

for activity: c: try intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

Sign up to request clarification or add additional context in comments.

3 Comments

hi, thanks for your suggestion. I've edited my question. I need to keep the history b4 it reach activity D.
hi, thanks for your suggestion. I've edited my question. I need to keep the history b4 it reach activity D.
maybe u can try keep serveal C states into a single activity?
1

Try Intent.FLAG_ACTIVITY_CLEAR_TOP each time you call startActivity() with the intent for B.

This will bring B to the top, popping all activities that were on top of it.

3 Comments

I need to set the flag at A->B or B->C?
i set the Intent.FLAG_ACTIVITY_CLEAR_TOP when activity B start activity C but no luck, when i press back button at activity D i stil go back to activity C.
set it when you are re-starting B after you've already pushed all your C's.
1
@Override
public void onBackPressed() {
Intent i = new Intent(ACTIVITY_D, ACTIVITY_B);     
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);        
    startActivity(i);
    return;
}

Override the onBackPressed() and set the FLAG_ACTIVITY_CLEAR_TOP flag. Place the function above under your activity D.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.