android 向模拟发送多点触摸事件~
来源:互联网 发布:贪吃蛇大作战源码 编辑:程序博客网 时间:2024/05/21 14:47
原贴 http://blog.csdn.net/ppcst/article/details/7255301
要向android发送系统多点触摸事件,发现网上有人问,但是没有人有答案~我也发过帖子没有人回答~搞了好久很搞出来~google真TMD不搞个文档,搞个例子~
贴下代码~下面是适合2.2的~
public boolean sendMoveDouble()
{
//point 1 release first
Log.i("key", "199199 send sendMovedoubl...........e");
Instrumentation inst = new Instrumentation();
MotionEvent e;
//nano
e=MotionEvent.obtainNano(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), System.nanoTime(),
0, 1, new int[]{0},
new float[]{bx1, by1, 1, 1}, 0,
0, 0, 0, 0);
Log.i("key", "199199 send sendMovedoubl...........1");
inst.sendPointerSync(e);
SystemClock.sleep(200);//Ms
e=MotionEvent.obtainNano(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), System.nanoTime(),
261, 2, new int[]{0, 1},
new float[]{bx1, by1, 1, 1, ex1, ey1, 1, 1}, 0,
0, 0, 0, 0);
Log.i("key", "199199 send sendMovedoubl...........2");
inst.sendPointerSync(e);
SystemClock.sleep(200);//Ms
e=MotionEvent.obtainNano(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), System.nanoTime(),
2, 2, new int[]{0, 1},
new float[]{bx2, by2, 1, 1, ex2, ey2, 1, 1}, 0,
0, 0, 0, 0);
Log.i("key", "199199 send sendMovedoubl...........3");
inst.sendPointerSync(e);
SystemClock.sleep(200);//Ms
e=MotionEvent.obtainNano(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), System.nanoTime(),
6, 2, new int[]{0, 1},
new float[]{bx2, by2, 1, 1, ex2, ey2, 1, 1}, 0,
0, 0, 0, 0);
inst.sendPointerSync(e);
SystemClock.sleep(200);//Ms
Log.i("key", "199199 send sendMovedoubl...........4");
e=MotionEvent.obtainNano(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), System.nanoTime(),
1, 1, new int[]{1},
new float[]{bx2, by2, 1, 1}, 0,
0, 0, 0, 0);
Log.i("key", "199199 send sendMovedoubl...........5");
inst.sendPointerSync(e);
return true;
}
MotionEvent.obtainNano这个函数是2.2的,在SDK中没有,你必须有android的源码,在源码中编译才能链接到!在sdk中提示没有这个函数
利用这个代码我在2.2中成功的实现了放大和缩小
- android 向模拟发送多点触摸事件~
- android 模拟发送多点触摸事件
- Android 向系统发送多点触摸事件总结
- Android多点触摸事件捕获
- android 单点和多点触摸事件
- android多点触摸事件的一些事
- 多点触摸模拟成功
- WPF4 多点触摸事件
- Android-单点触摸-多点触摸
- iOS模拟器模拟多点触摸
- android多点触摸demo
- Android 多点触摸接口
- android多点触摸demo
- Android : 多点触摸
- android 多点触摸实例
- Android 多点触摸
- Android 多点触摸
- Android 多点触摸接口
- Android Itext调查文档
- python手记(2)
- jvm工作原理
- springMVC修改配置文件路径与给页面传递数据
- PHP5.5 新特征
- android 向模拟发送多点触摸事件~
- 数据库连接池问题weblogic-oracle
- 监控文件变化的三种方法
- ----Ubuntu 12.04下安装Java6的方法
- SipUA 下载 编译
- 如何删除Java集合中的元素
- eclipse如何使用插件
- 新手上路,请多多关照
- Java基础—方法重载与方法重写