android 模擬事件

1.須要系統權限  html

Instrumentation inst=new Instrumentation();
inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 240, 400, 0));
inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 240, 400, 0));

2. 命令格式:adb shell sendevent [device] [type] [code] [value]
android

http://blog.csdn.net/lichaoandy/article/details/6565893
shell

http://www.itivy.com/android/archive/2011/9/8/the-difference-between-android-touch-screen.html
spa

http://blog.csdn.net/myarrow/article/details/7254651
.net

3. code

shell@m0:/ $ input
input
usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input [touchscreen|touchpad|touchnavigation] tap <x> <y>
       input [touchscreen|touchpad|touchnavigation] swipe <x1> <y1> <x2> <y2> [duration(ms)]
       input trackball press
       input trackball roll <dx> <dy>
相關文章
相關標籤/搜索