1

Is there a way to inject keystrokes into the JVM on the Android platform?

I'm looking for something like java.awt.Robot but I don't think that's available on Android

thanks

4

3 回答 3

3

听起来您需要 InstrumentationTestCase.sendKeys()

http://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendKeys(java.lang.String )

http://developer.android.com/reference/android/view/KeyEvent.html

于 2010-10-24T20:35:24.367 回答
2

您可以使用:

$ adb -s <serialno> emu event send <event>

其中事件描述可能类似于:

"EV_KEY:KEY_A:1"
于 2010-10-24T21:13:58.717 回答
0

好吧,我实际上正在开发 android (synergy-foss.org) 的 Synergy 端口,我认为在设备本身上伪造击键的最佳(也是唯一方法)是写入 /dev/input/uinput。但是,这似乎仅适用于 Cyanogen mod

于 2010-10-25T12:58:17.973 回答