1

In my app have a sign in activity. If login is successful, I start the first activity. It includes the menu, which opens ActivityA, ActivityB, ActivityC... and from these activities I can go deeply ActivityASubA and deeper ActivityASubB...

-ActivityA
--ActivityASubA
--ActivityASubB

-ActivityB
--ActivityBSubA
--ActivityBSubB

...

And if the user open ActivityA and ActivityASubA and later from the menu ActivityB and after that sign out, I open the sign in activity, but in the history will be the previous activities and if he press back see again these activities and it's a problem.

So when sign out I need to close all activity. Which is the best solution?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Robertoq
  • 559
  • 1
  • 10
  • 21
  • I think the same approach as in http://stackoverflow.com/questions/7486865/remove-or-close-your-own-activity-window-from-a-status-bar-notification-intent/ can be followed. – Marc Van Daele Mar 29 '12 at 18:16

1 Answers1

1

In sign out method you should put this code:

Intent intent = new Intent(this, Home.class);  
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
startActivity(new Intent(this, Home.class));  
finish();  

About FLAG_ACTIVITY_CLEAR_TOP you can read th

Alex Klimashevsky
  • 2,457
  • 3
  • 26
  • 58