Android: 用Instrumentation类发送鼠标或按键事件
16lz
2022-04-01
模拟鼠标MotionEvent.ACTION_DOWN:
new Thread () { public void run () { try { 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)); } catch(Exception e) { Log.e("Exception when sendPointerSync", e.toString()); } } }.start();
更多相关文章
- android 模拟器中找不到程序
- Android(安卓)启动模拟器是出现“Failed to allocate memory: 8
- Android(安卓)模拟器安装及使用教程
- 32位ubuntu10.04编译Android4.0.1内核
- android常用命令
- Android开发工具使用之adb
- 如何在电脑上安装模拟器体验Android(安卓)4.0
- [Android--Tool][INSTALL_FAILED_INSUFFICIENT_STORAGE]问题及解
- Android(安卓)Studio 1.0 (稳定版) 完全攻略