Search code examples
google-glassgoogle-gdk

Can I make an options menu the root of the stack?


In MainActivity I've implemented the onCreateOptionsMenu method and I'm calling openOptionsMenu() from onCreate. This all works as expected.

The only issue is that the user can swipe down to close the menu which leaves them on an empty card. Swiping again shows the clock and "ok, glass".

Can I make it so that the open menu is the only thing in the stack?


Solution

  • You can get this behavior if you override onOptionsMenuClosed in your activity and call finish(). Note that onOptionsMenuClosed gets called both when the menu is canceled and when an item is selected though, so if you want to do something else when a menu item is selected, you'll need to keep track of that fact in onOptionsItemSelected and check it inside onOptionsMenuClosed.