basically my app has a loginScreen and once logged u can go through many activities. when i press the home button the app goes in background and if the user doesnt open it within a certain amount of time, the users session closes and u return to the loginScreen. now the problem is that if i want to close the app from the loginScreen once my session has expired i press the back key and it should close but it doesnt. it brings me to the previous element in the stack.
the wired thing is that on all onBackPressed() methods and when ever i started new intents i always use intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
and on the loginScreen onBackPressed() i call finish()
but it doesnt work. anyone know why? and how do i solve this problem.
Thanks for the help!!!
code snippets
in many activities:
@Override
public void onBackPressed() {
mpButtonClick.start();
Intent intent = new Intent(this, MenuPagina.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
super.onBackPressed();
}
in the loginActivity:
@Override
public void onBackPressed() {
super.onBackPressed();
getIntent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
LoginActivity.this.finish();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…