小编Thi*_*ika的帖子

辅助功能服务dispatchGesture无法按预期工作,它只是偶尔执行手势?

我正在尝试构建一个带有光标的单手选项替代方案,以使用光标到达 Android 设备的高端。我使用触摸侦听器通过屏幕下半部分的跟踪器跟踪移动并识别用户的点击,并尝试在指针所在的位置执行这些点击。它有时有效,有时无效,我不明白为什么?

我已在服务元数据中包含 android:canPerformGestures="true" 。

这是我用来执行点击手势的代码

        // duration must be set in ms according to long click or simple click
        long duration;
        if (isLongClick){
            duration = 400L;
        }else{
            duration = 103L;
        }

        GestureDescription.Builder builder = new GestureDescription.Builder();

        Point point = new Point(cursorParams.x,cursorParams.y);

        Path path = new Path();
        path.moveTo( point.x, point.y);
        path.lineTo( point.x + 50, point.y + 50);

        GestureDescription.StrokeDescription clickStroke =
                new GestureDescription.StrokeDescription(path,10, duration);

        builder.addStroke(clickStroke);
        GestureDescription description = builder.build();
        boolean isDispatched = dispatchGesture(description, new GestureResultCallback() {
            @Override
            public void onCompleted(GestureDescription …
Run Code Online (Sandbox Code Playgroud)

android accessibility android-service

6
推荐指数
0
解决办法
1795
查看次数

标签 统计

accessibility ×1

android ×1

android-service ×1