Skip to content Skip to sidebar Skip to footer

How Can I Use Accessibilityservice.getwindows() To Obtain A Traversable Accessibilitynodeinfo?

I am writing an AccessibilityService for Android and, up to API level 20, I have been using the AccessibilityEvent.getSource() method to obtain a traversable AccessibilityNodeInfo

Solution 1:

You can get access of windows content using getChild() method. In your onAccessibilityEvent(AccessibilityEvent event) you can do like below.

@OverridepublicvoidonAccessibilityEvent(AccessibilityEvent event) {
          AccessibilityNodeInfomSource= event.getSource();
          intchild= mSource.getChildCount();
          // iterate through all child of parent viewfor (int i=0; i<child; i++){
            AccessibilityNodeInfochildNodeView= mParent.getChild(i);
            // Do something with this window content
          }
}

Solution 2:

getNodesFromWindows() is only returning a List of root nodes. You need to iterate through its children to collect all nodes in the window.

Post a Comment for "How Can I Use Accessibilityservice.getwindows() To Obtain A Traversable Accessibilitynodeinfo?"