Example usage for android.hardware.input InputManager INJECT_INPUT_EVENT_MODE_ASYNC

List of usage examples for android.hardware.input InputManager INJECT_INPUT_EVENT_MODE_ASYNC

Introduction

In this page you can find the example usage for android.hardware.input InputManager INJECT_INPUT_EVENT_MODE_ASYNC.

Prototype

int INJECT_INPUT_EVENT_MODE_ASYNC

To view the source code for android.hardware.input InputManager INJECT_INPUT_EVENT_MODE_ASYNC.

Click Source Link

Document

Input Event Injection Synchronization Mode: None.

Usage

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);
    }/*from  w  ww .  j  a  v  a2  s  .  co  m*/
}