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 执行触摸和按住手势?
最佳答案
Is there any way to perform touch and hold gesture using AccessibilityService?
我认为您需要确定手势
willContinue
或不。然后,根据您的代码,我建议更改:GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1);
至:
GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1, true);
只需添加
true
到 StrokeDescription
的最后一个参数. PS :这仅适用于 Android 8+。
关于android - 如何使用 AccessibilityService 执行触摸并按住手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59555188/