I have an input method which simulates key press as such:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, event));
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, event));
With this method I can open the menu on the device using KeyEvent.KEYCODE_MENU
. After i've done this I try to send KeyEvent.KEYCODE_DPAD_UP
AND KeyEvent.KEYCODE_DPAD_DOWN
to browse the menu, but the focus is still on the activity in the background.
So, for example, when I'm at the launcher, I open the menu, but when I press up or down, the device is browsing the apps on my home screen instead of the options in the menu.
I repeated the same steps with a hardware keyboard, and then the focus jumps to the menu as expected, so I feel this should be able to simulate as well.