I would like to open the optionsMenu programmatically without a click on the menu key from the user. How would I do that?
After a long research and many tries, the only way seems to be simulating a KeyEvent. This makes the options menu appear:
BaseInputConnection mInputConnection = new BaseInputConnection( findViewById(R.id.main_content), true);
KeyEvent kd = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
KeyEvent ku = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU);
mInputConnection.sendKeyEvent(kd);
mInputConnection.sendKeyEvent(ku);