Android inject input events 注入Touch 点(x, y) 触摸输入事件

  • Post author:
  • Post category:其他


1. 使用Instrumentation

new Thread(new Runnable() {
            @Override
            public void run() {
                Instrumentation mInst = new Instrumentation();

                mInst.sendKeyDownUpSync(KeyEvent.KEYCODE_A); //按键事件

                mInst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMilis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, point.x, point.y, 0); //触摸按下
                mInst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMilis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, point.x, point.y, 



版权声明:本文为zjwfan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。