Ghost activity in android

Posted by Ari on Stack Overflow See other posts from Stack Overflow or by Ari
Published on 2013-11-08T14:28:27Z Indexed on 2013/11/08 21:54 UTC
Read the original article Hit count: 89

My application works as follow:

On start I have some AppStartActivity which does something, finishes itself and starts MainActivity if user is logged in or LoginActivity otherwise.

LoginActivity finishes itself and starts MainActivity when user log in successfully.

On MainActivity I have SomeActivity from which user can logout. Activity stack for this situation is MainActivity > SomeActivity. It is correct, back button works well. When user click LogOut button there is a problem. I need to show LoginActivity but I don't want to have MainActivity and SomeActivity on activity stack anymore.

I could resolve this problem if I wouldn't finish AppStartActivity. I could go back then with flag FLAG_ACTIVITY_CLEAR_TOP and it would work well. But here is a problem with back button. I don't want user to come back to this activity with back button. I want it to exit app instead.

UPDATED:

Flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK would be best, but I need it working in API level 9.

© Stack Overflow or respective owner

Related posts about java

Related posts about android