我想将一些String发送到Android中的其他应用程序,在这种情况下,我正在使用Instrumentation,但只能读取小写字母。

Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_A);


如何将小写更改为大写?
注意:不要使用“ sendStringSync”方法,因为它很慢。

问候

最佳答案

试试这个代码:

Instrumentation inst = new Instrumentation();
inst.sendStringSync("A");


要么

Instrumentation inst = new Instrumentation();
KeyEvent keyEvent=new KeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT,KeyEvent.KEYCODE_A);
inst.sendKeySync(keyEvent);

08-28 14:22