Android unable read window content on few devices using accessibility service

前端 未结 3 811
一整个雨季
一整个雨季 2020-12-18 02:48

My requirement: Reading the text from pop up, dialog etc for particular app.

I have implemented an accessibility service and I am receiving proper events and data as

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 03:07

    you should check whether there are any sub child for child nodes.

    private void clickPerform(AccessibilityNodeInfo nodeInfo)
     {
       if(nodeInfo != null)
     {
    
                for (int i = 0; i < nodeInfo.getChildCount(); i++) {
                    AccessibilityNodeInfo childNode = nodeInfo.getChild(i);
                    Log.e("test", "clickPerform: "+childNode );
                    if (childNode != null) {
                        for (int j = 0; j <= childNode.getChildCount(); j++) {
                            AccessibilityNodeInfo subChild = childNode.getChild(i);
    
                            if (String.valueOf(subChild.getText()).toLowerCase().equals("ok")) {
                                subChild.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                            } else {
                                Log.e("t2", "clickPerform: ");
                            }
                        }
                    }
    
                    }
                }
    }
    

提交回复
热议问题