When I have two activities
Activity A, B;
// A stands for Login Screen
// B stands for Main Application Screen
Application starts with A, then user performs login and he will be pointed to B
When I launch B I add this flag to Intent Intent.FLAG_ACTIVITY_CLEAR_TOP but when I finish the B I expect it to be the last activity and to quit the application.
Instead of what I expected, A is brought to front, and user stills on Login Screen again.
Should I start A from B as startActivityForResult and use B as main activity of whole application ?
Or the flag is not working as it should be?
Don’t bother with intent flags. When activity A starts activity B after a successful login, just have A call
finish().An alternative, slightly more involved, approach is to make B your main activity and in B’s
onCreatemethod, start activity A for a result, which should be some pass/fail flag. When Activity A finishes (either on a successful login, failure, or the user just quitting), activity B determines inonActivityResultwhether to continue or to finish, based on the returned value. This works because, according to the docs: