I am programming a remote control application. One of the tasks is to enter characters. The code I use is as follows:
Instrumentation instr = new Instrumentation(); String str="a";
This works great on English characters (characters are displayed in EditText blocks). However, if I try to introduce, for example, Korean characters, this fails. The getEvents function returns null even if I configured the Korean language and keyboard.
I know that there is another method for directly entering lines:
KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(), str, 0, 0); instr.sendKeySync(event);
This also does not work - no characters are displayed in EditText blocks, and onKeyMultiple () is not called in my test activity.
This is strange, since dispatchKeyEvent () with the same event works in my test activity:
KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(), str, 0, 0); dispatchKeyEvent(event);
My remote control application should fire events no matter what action. This is possible using Instrumentation (with android.permission.INJECT_EVENTS and a signature with a platform key).
How can I enter non-English characters using the toolkit? Is there any other way to do this? For example. Using dispatchKeyEvent (should work for other actions / applications).
kahlk
source share