Fran├žois Adam
May 29, 2017
3:40 pm

Remote Injection : injectKeyEvent not working properly

Hello,

I'm currently trying to implement the examples of the Remote Injection API documentation (https://seap.samsung.com/api-references/android-standard/reference/andro...).

The injectPointerEvent example is working perfectly fine. However the injectKeyEvent example is not working properly, I've tried with the following code which makes my app crash :

RemoteInjection remoteInjection = RemoteInjection.getInstance();
remoteInjection.injectKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_T), true);
remoteInjection.injectKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_T), true);

I've also tried to use another method which is also not working :

RemoteInjection remoteInjection = RemoteInjection.getInstance();
remoteInjection.injectKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), text, InputDevice.SOURCE_KEYBOARD, 0), true);

But after using this one, my app is still working (even though the method itself doesn't seem to have done anything).
Can you please tell me if I am missing something there or if it's an issue on the API's side.

Thanks,

Fran├žois.