Reputation: 12678
Once a user signs out (from the preferences), the handler signs the user out and them takes them to the initial launch page.
The only problem is the user can hit the 'back' button which takes them to the other activities where they can see the info from the logged in person. What i want to do is make it work like someone has just opened the app for the first time when they have signed out.
I've tried to send the intent of starting the activity with 'FLAG_ACTIVITY_CLEAR_TOP' and 'SINGLE_TOP' flags but it doesn't seem to work.
Thanks
Upvotes: 1
Views: 109
Reputation: 14815
There are two things you can do, the first of which you've tried but isn't working for some reason.
One is to clear the back button stack when you launch your activity like this: myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
though I'm not sure why that's not working for you.
The other thing you can do is override the back button handling in your login activity so that it doesn't do anything. Here is example code to accomplish that:
@Override
public void onBackPressed()
{
return;
}
Upvotes: 0
Reputation: 64700
Try the FLAG_ACTIVITY_CLEAR_TASK option.
EDIT: just noticed that this is only in API 11. You'll probably need to do something like registering a BroadcastReceiver in all your Activities, then on the logout screen send an Intent that the BroadcastReceiver will catch. The Activity can then cleanly exit.
Upvotes: 1