I am wanting a certain flag in my code to be set when a menu is on screen. I tried catching the keyCode == KeyEvent.KEYCODE_MENU event in onKeyDown to detect when the menu would appear – but then if the menu button is pressed a second time (making the menu disappear), there is no keyCode == KeyEvent.KEYCODE_MENU event.
Should I look for some other event, or is there a function to test if some kind of menu is on display?
To catch the menu being opened, you can override
To catch the menu being closed, you can override
However keep in mind that the second one will be called both when the user presses “menu” button the second time or taps one of the menu options. Therefore you’ll need to use it in combination with