如何使用 AccessibilityService 执行触摸和保持手势? [英] How to perform a touch and hold gesture using AccessibilityService?

查看:58
本文介绍了如何使用 AccessibilityService 执行触摸和保持手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Path clickPath = new Path();
clickPath.moveTo(x, y);
GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1);
GestureDescription.Builder clickBuilder = new GestureDescription.Builder();
clickBuilder.addStroke(clickStroke);
dispatchGesture(clickBuilder.build(), null, null);

使用此代码,我可以在屏幕上的任何位置执行单击操作.有没有办法使用 AccessibilityService 执行触摸和保持手势?

With this code I can perform clicks anywhere on the screen. Is there any way to perform touch and hold gesture using AccessibilityService?

推荐答案

有没有办法使用 AccessibilityService 执行触摸和保持手势?

Is there any way to perform touch and hold gesture using AccessibilityService?

我认为您需要决定手势 willContinue 与否.然后,根据您的代码,我建议更改:

I think that you need decide if the gesture willContinue or not. Then, based in your code i suggest change:

GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1);

致:

GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1, true);

只需将true 添加到StrokeDescription 的最后一个参数.PS:这仅适用于 Android 8+.

Simply, add true to last parameter of StrokeDescription. PS: this works only from Android 8+.

这篇关于如何使用 AccessibilityService 执行触摸和保持手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆