How to get source of Child Node of an Activity Using Accessibility in Android

1.8k views Asked by At

i am trying to get a source of all nodes in a activity using accessibility in android. first when user focuses on a EditText it will get the parent of the Focused EditText. Using the parent i will get the all child element of an Activity. i can get the Source of a Focused EditText by calling event.getSource(), but i can't get the source of all child elements i tried a something but i can't get source of the child nodes, Why i need source because using that only i can paste some text in the nodes.

Code.

public void onAccessibilityEvent(AccessibilityEvent event){
            AccessibilityNodeInfo source = event.getSource();
            AccessibilityNodeInfo pass1;
            AccessibilityNodeInfo par=source.getParent();
            int count = par.getChildCount();
            for(int i=0;i<count;i++){
                pass1 = par.getChild(i);
                if(pass1.isPassword()){
                      ClipboardManager clipboard = (ClipboardManager) MyAccessibilityService.this.getSystemService(Context.CLIPBOARD_SERVICE);
                      ClipData clip = ClipData.newPlainText("label", "TEST DATA");
                      clipboard.setPrimaryClip(clip);
                      source.performAction(AccessibilityNodeInfo.ACTION_PASTE);
                }
                }

so here how can i get the source the of a child nodes. i paste the text to focused EditText by getting the source of the focused node. if there is no way to get the source of a child node then how can i paste the some text to that child node? Is this possible please give ideas...

0

There are 0 answers