I'm stuck in a situation, please help me. This is problem. I have a menu screen in my application. Now you have the opportunity to return to the menu on all screens that did not come directly from the menu screen. For example, I go to Activity B as Menu -> Activity A -> Activity B. Now I wrote a button press backtoMenu.
this.finish();
startActivity(new Intent(SelectStateActivity.this,MenuScreen.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
I do not end Activity A because I want to be in action A when I press the button in action B. It will be on the stack when I press the menu button in Activity B. I come to the menu screen, but that’s fine, but when I I click on the menu screen, I am in Activity A., which is not needed. 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 they didn’t work. Please help me.