简体   繁体   English

Android:远程点击屏幕

[英]Android: tap screen remotely

Is it possible to implement something like this on Android?是否可以在 Android 上实现类似的东西?

Let's say I have an Android device running an app (not mine).假设我有一个运行应用程序(不是我的)的 Android 设备。 It will always be the same app with the same view.它将始终是具有相同视图的同一个应用程序。 I need the device to trigger touch on a specific screen location whenever I need it to.我需要设备在需要时触发特定屏幕位置的触摸。

  1. I create a request on the server我在服务器上创建一个请求
  2. Android device checks for requests periodically Android 设备定期检查请求
  3. Whenever a new request is found, it touches the screen at X and Y每当找到新请求时,它都会在 X 和 Y 处触摸屏幕
  4. It sends a response that the request is done它发送请求完成的响应

You can programmatically dispatch touch actions on a view.您可以在视图上以编程方式调度触摸操作。

public void TouchView(View view, Float x, Float y)
{
    view.dispatchTouchEvent(MotionEvent.Obtain(SystemClock.UptimeMillis(), SystemClock.UptimeMillis(), (int)MotionEventActions.Down, x, y, 0));
    view.dispatchTouchEvent(MotionEvent.Obtain(SystemClock.UptimeMillis(), SystemClock.UptimeMillis(), (int)MotionEventActions.Up, x, y, 0));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM