I have a problem in all my activities, when I press the back button it works properly, but when I press the context menu button before, nothing happens when I press back. I am talking about the phone buttons, not the toolbar icon for back navigation. Has anyone ever dealt with this?
EDIT: No menu shows, onPrepareOptionsMenu() is removed, the phone vibrates when I press back but no action. I see that if I inflate a menu, it worsk properly after the first back that closes te popup.
I see that this happens only if I set the toolbar with setSupportActionBar(toolbar);
I have nearly the same problem, this is my case:
All works fine until i press the device menu button, then the app begins to ignore the back button.
This is what i have seen after pressing the device menu button
I don't know why the onBackPressed stops from being called, tried without overriding onBackPressed and onKeyUp and the problem is still the same.
I know this is not the best solution, but to fix this problem i'm using the next code:
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_BACK){
onBackPressed();
return true;
}
return super.onKeyUp(keyCode, event);
}
Hope this helps.