The problem is very simple. I have to simulate the dpad events (UP,DOWN,RIGHT,LEFT,CENTER) for navigate in my GUI that consists of a lot of buttons and other elements. With the simulator D-Pad I can without a line code navigate throw this GUI. But how can I do this programmatically?
I have tried a lot with no success:
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_LEFT); View.dispatchKeyEvent(event);
Nothing happens (the focus should move one element to right)I have also read a lot about windowManager.injectKeyEvent but found nothing that works.
- And also Instrumentation can help for simulating keyevents but more for testing, not for use in the application itself.
I think there is a solution, because talkback can simulate the physical D-Pad (http://code.google.com/p/eyes-free/source/browse/trunk/ime/latinime/src/com/googlecode/eyesfree/inputmethod/latin/LatinIME.java)