gpt4 book ai didi

android - API 24 AccessibilityService.dispatchGesture() 方法如何工作?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:14:25 57 4
gpt4 key购买 nike

通过 API 24,我们找到了一种向设备发送手势的方法,但是目前还没有可靠的文档或示例。我正在尝试让它工作,但目前手势每次都会触发“onCancelled”回调。

这是我调用该方法的代码:

@TargetApi(24)
private void pressLocation(Point position){
GestureDescription.Builder builder = new GestureDescription.Builder();
Path p = new Path();
p.lineTo(position.x, position.y);
p.lineTo(position.x+10, position.y+10);
builder.addStroke(new GestureDescription.StrokeDescription(p, 10L, 200L));
GestureDescription gesture = builder.build();
boolean isDispatched = dispatchGesture(gesture, new GestureResultCallback() {
@Override
public void onCompleted(GestureDescription gestureDescription) {
super.onCompleted(gestureDescription);
}

@Override
public void onCancelled(GestureDescription gestureDescription) {
super.onCancelled(gestureDescription);
}
}, null);

Toast.makeText(FingerprintService.this, "Was it dispatched? " + isDispatched, Toast.LENGTH_SHORT).show();
}`

有没有人使用过这种新方法或知道如何让它发挥作用的示例?

最佳答案

您的路径只是 lineTo,它没有指定起点。尝试将第一个更改为 moveTo

关于android - API 24 AccessibilityService.dispatchGesture() 方法如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39283640/

57 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com