「已注销」 2023-08-26 16:23 采纳率: 25%
浏览 11
已结题

AccessibilityService无障碍遇到的问题

练习做一个跳过广告的软件,我用weditor定位到关闭按钮,但是用performAction(AccessibilityNodeInfo.ACTION_CLICK)点击无效。

textNodeInfoList.get(0).isClickable()
//返回false
List<AccessibilityNodeInfo> textNodeInfoList = sourceNodeInfo.findAccessibilityNodeInfosByText("关闭");
//这里能获取关闭节点。

定位元素截图两张,各位帮我看看,具体该怎么做!

img

img

  • 写回答

3条回答 默认 最新

  • Java毕设王 2023-08-26 16:54
    关注

    你可以试试其他方法,java的这个

    
    Rect bounds = new Rect();
    textNodeInfoList.get(0).getBoundsInScreen(bounds);
    int x = bounds.centerX();
    int y = bounds.centerY();
    GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
    Path path = new Path();
    path.moveTo(x, y);
    gestureBuilder.addStroke(new GestureDescription.StrokeDescription(path, 0, 100));
    GestureDescription gestureDescription = gestureBuilder.build();
    dispatchGesture(gestureDescription, new GestureResultCallback() {
        @Override
        public void onCompleted(GestureDescription gestureDescription) {
            super.onCompleted(gestureDescription);
            // 点击完成后的操作
        }
    });
    
    
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月27日
  • 修改了问题 8月26日
  • 创建了问题 8月26日