Android:通过ADB进行屏幕触摸事件
我知道以下将在设备上发送触摸事件 (5,29)。
adb shell sendevent /dev/input/event0 3 0 5
adb shell sendevent /dev/input/event0 3 1 29
adb shell sendevent /dev/input/event0 1 330 1
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 1 330 0
adb shell sendevent /dev/input/event0 0 0 0
然而,在真机上尝试,却不起作用。 (尝试过 Nexus S、HTC G2 root)
我使用
cat /proc/bus/input/devices
或
getevent
来找出哪个事件#是触摸事件并发送上面的代码,但没有运气。 (实际上我尝试了所有事件#,但没有一个起作用)
如何在真实设备上使用 ADB 发送触摸事件?
对于关键事件,我知道有:
input keyevent <event_code>
触摸事件有这样的事件吗?
我知道我可以记录/回放触摸事件。但是,我要求以编程方式发送触摸事件。
Referencing this thread:
http://groups.google.com/group/android-beginners/browse_thread/thread/8a5d8fa9229114d2/ce6e604f52b5318f?pli=1
I know following will send a touch event (5,29) on the device.
adb shell sendevent /dev/input/event0 3 0 5
adb shell sendevent /dev/input/event0 3 1 29
adb shell sendevent /dev/input/event0 1 330 1
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 1 330 0
adb shell sendevent /dev/input/event0 0 0 0
However, trying on the real device, it doesn't work. (Tried Nexus S, HTC G2 rooted)
I used
cat /proc/bus/input/devices
or
getevent
to find out which event# is the touch events and send the above code, but no luck.
(Actually I tried all event#s, but none of them work)
How do I send touch events using ADB on real devices?
For key events, I know there's:
input keyevent <event_code>
Is there such one for touch events?
I know I can record/playback touch events. However, I am asking for programmatically sending touch events.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅https://stackoverflow.com/a/18959385/1587329处的答案(稍作修改):
See the (slightly adapted) answer at https://stackoverflow.com/a/18959385/1587329:
使用View类的dispatchTouchEvent(MotionEvent event)方法发送触摸(down,move,up)事件
Use dispatchTouchEvent (MotionEvent event) method of View class to send touch (down,move,up) events