I have an application with several Activities in Android and I want the user to be able to log-out by pressing a menu button. The problem I have is that
A) Android doesn't let you terminate the application and
B) even when I send the user to the LoginActivity
again they can always press back and get right back to the previous activity they were in.
I already tried to launch the Activity with the two following flags:
Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
I also tried with each one of them by themselves.
I also tried calling finish()
after startActivity(intent)
as I read in another StackOverflow
question.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…