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执行触摸并保持手势?
可以使用AccessibilityService进行触摸并保持手势吗?
我认为您需要确定是否手势willContinue
。然后,根据您的代码,我建议更改:
willContinue
收件人:
GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1);
简单地,将GestureDescription.StrokeDescription clickStroke = new GestureDescription.StrokeDescription(clickPath, 0, 1, true);
添加到true
的最后一个参数。 PS:仅适用于Android 8 +。