I'm wondering why I can't clear everything from the stack and go to one activity. I've done my fair share of googleing and it seems that I'm supposed to use FLAG_ACTIVITY_CLEAR_TOP in my intent. However, it does not seem to work

My call stack goes something like this:
A -> B -> C ->D -> B
Now when I'm on B, I want to clear everything and start fresh at A (i.e. back button should not go back to B, but quit). The closest description I've seen is that of FLAG_ACTIVITY_CLEAR_TOP followed by FLAG_ACTIVITY_NEW_TASK. However, neither work for me, as I can still go through the entire activity stack with the back button. This is obviously unacceptable in an application with logins.
Here's the code that I've tried:
- Code: Select all
Intent myIntent = new Intent(Intent.ACTION_MAIN);
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(myIntent);
OR
- Code: Select all
Intent i = new Intent();
i.setClass(Main.this, Login.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
I've tried the activities without FLAG_ACTIVITY_NEW_TASK and without FLAG_ACTIVITY_CLEAR_TOP, neither of which seem to have any effect.
Any help would be greatly appreciated


