Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to implement logout beaviour in android

I have an application which works when the user logs in. However, whenever there is a request to server and the reply contains session_expired, I need to clear the activity stack and show user just the login screen. This should be trivial however I am not able to find out a proper way to approach this without littering finish() inside every activity with conditional code. How can I just clear the activity stack and push just one activity? My application requires android 2.2 and up. I understand that it was introduced a new intent flag in honeycomb in order to just do that, but I need to support it for froyo and gingerbread also.

like image 346
Vaibhav Mishra Avatar asked Oct 23 '22 18:10

Vaibhav Mishra


1 Answers

You can use FLAG_ACTIVITY_CLEAR_TOP

http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP

like image 186
kikoso Avatar answered Nov 01 '22 12:11

kikoso