android 模拟事件

1.需要系统权限 

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]

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

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

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

3.

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>





你可能感兴趣的:(android 模拟事件)