操作系统更新后,MotionEvent.obtain(..)无法正常工作

时间:2020-10-21 13:12:09

标签: android android-studio touch motionevent

我一直在使用MotionEvent.obtain方法在应用程序上以编程方式使用点击事件

在更新操作系统后,它无法正常运行,之前运行良好。在纵向模式下可以正常工作,但在横向模式下可以单击随机位置。

示例代码:-

   dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),
     SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, 0));
   dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),
     SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0));

0 个答案:

没有答案