Changing the configuration of an Android device (for example, βslide the hard keyboard backβ) will always call PhoneWindow.onConfigurationChanged()
, which in turn will call reopenMenu()
. This will re-open the menu of the current activity, if it is displayed.
I have a lock in my menu implemented in my onPrepareOptionsMenu()
override. The user must enter the code every time he wants to see the menu. I do not want the user to be asked to enter the code again, and the menu is still only due to a configuration change. So, I would like to know if there is a way to check if the menu of the current foreground activity is displayed? Knowing this, I can bypass the access code request if the menu has already been completed.
My custom temporary implementation is to use my own menuShowing
flag, which I set to onPrepareOptionsMenu
and reset to onOptionsItemSelected
and onKeyDown
if the back button is pressed.
EDIT:
It seems that changing the screen orientation configuration does not cause this behavior. However, a hard keyboard slide does.
source share