I have a menu on my application. The problem is that, when I click on an item, the previous one stays behind. So when I click on the previous button of my phone, the previous activity appears. I don't know what is going wrong with my code.
So this is my code for the menu :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_user:
Intent intent1 = new Intent(TeamActivity.this, UserActivity.class);
startActivity(intent1);
return true;
case R.id.action_team:
return true;
case R.id.action_score:
Intent intent2 = new Intent(TeamActivity.this, ScoreActivity.class);
startActivity(intent2);
return true;
case R.id.action_settings:
Intent intent3 = new Intent(TeamActivity.this, SettingsActivity.class);
startActivity(intent3);
return true;
case R.id.action_about:
Intent intent4 = new Intent(TeamActivity.this, AboutActivity.class);
startActivity(intent4);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
I hope you understand, and sorry for my bad english
Simply add this.finish(); after each startActivity() before returning true!