List of usage examples for android.hardware.input InputManager injectInputEvent
@UnsupportedAppUsage public boolean injectInputEvent(InputEvent event, int mode)
From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java
private void sendKeyEvent(int keyCode, boolean down) { InputManager iMgr = (InputManager) getSystemService(INPUT_SERVICE); if (iMgr != null) { long time = SystemClock.uptimeMillis(); KeyEvent evt = new KeyEvent(time, time, down ? KeyEvent.ACTION_DOWN : KeyEvent.ACTION_UP, keyCode, 0); iMgr.injectInputEvent(evt, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC); }// w w w . j a v a2 s.c o m }