在应用程序外部发送 TouchEvents
我正在尝试在远程电话上执行 MotionEvent。 Phone A 获取 TouchEvent 并发送给 Phone B。 现在可以正常工作,但在电话 B 上分派 MotionEvent 时存在问题。
这是分派 MotionEvent 的示例,但仅在一次自己的视图(此处为电话 A)上:
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event1 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, 100,100, 0);
MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, 100, 100, 0);
dispatchTouchEvent(event1);
dispatchTouchEvent(event2);
我应该如何在电话 B 上分派 TouchEvent我不是我自己的View吗? 谢谢
I´m trying to execute an MotionEvent on a remote Phone.
The TouchEvent is obtained on Phone A and send to Phone B.
This is working by now but there is Problem with dispatching that MotionEvent on Phone B.
Here is an example for dispatching a MotionEvent, BUT only on once own View(here Phone A):
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event1 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, 100,100, 0);
MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_UP, 100, 100, 0);
dispatchTouchEvent(event1);
dispatchTouchEvent(event2);
How I am suppose to dispatch an TouchEvent on Phone B when I'm not my own View?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
幸运的是,出于明显的安全原因,这是不可能的。在单元测试之外,一个应用程序无法将事件注入到另一个应用程序中(这反过来又施加了自己的一组限制)。
Fortunately, that is not possible, for obvious security reasons. One application cannot inject events into another application, outside of unit testing (which in turn imposes its own set of restrictions).