I have got stuck in situation please help me .Here is the problem .I have a menu screen in my application.Now have given option to go back to menu to all screens that has not come directly from menu screen .For example I go to Activity B like Menu ->Activity A -->Activity B. Now I have written on pressing backtoMenu button.
this.finish();
startActivity(new Intent(SelectStateActivity.this,MenuScreen.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
I am not finishing Activity A because I want to be on activity A when I press back button on activity B.So it will be on stack when I press menu button on Activity B. I come to menu screen which is fine but when I press back on menu screen I come to Activity A.Which is not wanted.I also tried
this.finish();
startActivity(new Intent(SelectStateActivity.this,MenuScreen.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP));
and
startActivity(new Intent(SelectStateActivity.this,MenuScreen.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK));
But haven't worked.Please help me.