如何在安卓中使用Instrument.sendKeyDownUpSync(int键码)将小写更改为大写



我想将一些字符串发送到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);

最新更新