Clear all intents from the stack

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Clear all intents from the stack

Postby 0l33l » Sat May 02, 2009 9:25 am

Hey Guys,
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 :)
0l33l
Once Poster
Once Poster
 
Posts: 1
Joined: Sat May 02, 2009 9:17 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests