80,351
社区成员
发帖
与我相关
我的任务
分享
@RequiresApi(api = Build.VERSION_CODES.O)
static public GestureDescription CreateGestureDescription(){
Path dragRightPath = new Path();
dragRightPath.moveTo(200, 200);
dragRightPath.lineTo(400, 200);
long dragRightDuration = 500L; // 0.5 second
Path dragDownPath = new Path();
dragDownPath.moveTo(400, 200);
dragDownPath.lineTo(400, 400);
long dragDownDuration = 500L;
GestureDescription.StrokeDescription rightThenDownDrag =
new GestureDescription.StrokeDescription(dragRightPath, 0L,
dragRightDuration, true);
rightThenDownDrag.continueStroke(dragDownPath, dragRightDuration,
dragDownDuration, false);
GestureDescription.Builder clickBuilder = new GestureDescription.Builder();
return clickBuilder.addStroke(rightThenDownDrag).build();
}
Path path = new Path();
path.moveTo(200, 200);
path.lineTo(400, 200);
final GestureDescription.StrokeDescription sd = new GestureDescription.StrokeDescription(path, 0, 500, true);
Path path2 = new Path();
path2.moveTo(400, 200);
path2.lineTo(400, 400);
final GestureDescription.StrokeDescription sd2 = sd.continueStroke(path2, 0, 500, false);
HongBaoService.mService.dispatchGesture(new GestureDescription.Builder().addStroke(sd).build(), new AccessibilityService.GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
HongBaoService.mService.dispatchGesture(new GestureDescription.Builder().addStroke(sd2).build(), null, null);
}
@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
}
}, null);