android - Why onAccessibilityEvent(..) method of AccessibilityService is reading the same view many times? -


i using accessibilityservice determine text , coordinates of views of current application running in android device. on every event onaccessibilityevent(...) runs don't know how control these events. have used event.getsource() result of every window content changed. xml settings of accessibilityservice is:

<?xml version="1.0" encoding="utf-8"?> <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"     android:accessibilityeventtypes="typewindowcontentchanged|typeviewfocused"     android:accessibilityflags="flagincludenotimportantviews|flagreportviewids"     android:canretrievewindowcontent="true"     android:canrequesttouchexplorationmode="true"     android:packagenames="com.whatsapp"     android:accessibilityfeedbacktype="feedbackspoken"  /> 

and onaccessibilityevent(...) is:

@override     public void onaccessibilityevent(accessibilityevent event) {           log.e("myservice: ","get source output: "+event.getsource());         string get_cord= string.valueof(event.getsource());           log.e("myservice: ","window id is: "+window_id);       } 

and output getting is(i have highlighted text value in bold:

08-18 19:34:29.055 20131-20131/com.example.root.without_root e/myservice:: source output: android.view.accessibility.accessibilitynodeinfo@801b6813; boundsinparent: rect(0, 0 - 548, 46); boundsinscreen: rect(144, 1095 - 692, 1141); packagename: com.device; classname: android.widget.textview; **text: samsung**; error: null; maxtextlength: -1; contentdescription: null; viewidresname: com.whatsapp:id/name; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longclickable: false; enabled: true; password: false; scrollable: false; actions: [accessibilityaction: action_select - null, accessibilityaction: action_clear_selection - null, accessibilityaction: action_accessibility_focus - null, accessibilityaction: action_next_at_movement_granularity - null, accessibilityaction: action_previous_at_movement_granularity - null, accessibilityaction: action_set_selection - null]  08-18 19:34:29.058 20131-20131/com.example.root.without_root e/myservice:: source output: android.view.accessibility.accessibilitynodeinfo@801b6813; boundsinparent: rect(0, 0 - 548, 46); boundsinscreen: rect(144, 1095 - 692, 1141); packagename: com.device; classname: android.widget.textview; **text: samsung**; error: null; maxtextlength: -1; contentdescription: null; viewidresname: com.whatsapp:id/name; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longclickable: false; enabled: true; password: false; scrollable: false; actions: [accessibilityaction: action_select - null, accessibilityaction: action_clear_selection - null, accessibilityaction: action_accessibility_focus - null, accessibilityaction: action_next_at_movement_granularity - null, accessibilityaction: action_previous_at_movement_granularity - null, accessibilityaction: action_set_selection - null]  08-18 19:34:29.061 20131-20131/com.example.root.without_root e/myservice:: source output: android.view.accessibility.accessibilitynodeinfo@801b6813; boundsinparent: rect(0, 0 - 548, 46); boundsinscreen: rect(144, 1095 - 692, 1141); packagename: com.whatsapp; classname: android.widget.textview; **text: samsung**; error: null; maxtextlength: -1; contentdescription: null; viewidresname: com.device:id/name; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longclickable: false; enabled: true; password: false; scrollable: false; actions: [accessibilityaction: action_select - null, accessibilityaction: action_clear_selection - null, accessibilityaction: action_accessibility_focus - null, accessibilityaction: action_next_at_movement_granularity - null, accessibilityaction: action_previous_at_movement_granularity - null, accessibilityaction: action_set_selection - null] 08-18 19:34:29.064 20131-20131/com.example.root.without_root e/myservice:: source output: android.view.accessibility.accessibilitynodeinfo@801b6bd4; boundsinparent: rect(0, 0 - 548, 38); boundsinscreen: rect(144, 1141 - 692, 1179); packagename: com.whatsapp; classname: android.widget.textview; text: ☺; error: null; maxtextlength: -1; contentdescription: null; viewidresname: com.whatsapp:id/status; checkable: false; checked: false; focusable: false; focused: false; selected: false; clickable: false; longclickable: false; enabled: true; password: false; scrollable: false; actions: [accessibilityaction: action_select - null, accessibilityaction: action_clear_selection - null, accessibilityaction: action_accessibility_focus - null, accessibilityaction: action_next_at_movement_granularity - null, accessibilityaction: action_previous_at_movement_granularity - null, accessibilityaction: action_set_selection - null] 

now can see ran 3 times 1 view want run single time 1 view. please me find out how can make possible?

i have tried changing values of accessibilityeventtypes in xml "typeallmasks" "typewindowcontentchanged" , "typeviewfocused" nothing helped me out.

i have tried setup flags in onaccessibilityevent(...) of accessibilityservice didn't worked because service keeps on running everytime(it great if can make work).

please tell me how can make work!

accessibility events happen frequently. so, first, consider whether or not want ignore these events. user experience issue looking address?

in particular, issues going happen lot windowcontentchanged events , viewfocused events. 1 thing consider doing throttling events. following change service config xml limit each specific event type happening once ever half second.

the event notification timeout useful avoid propagating events client since accomplished via expensive interprocess call. 1 can think of timeout criteria determine when event generation has settled down.

so, service config xml this:

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" android:accessibilityeventtypes="typewindowcontentchanged|typeviewfocused" android:accessibilityflags="flagincludenotimportantviews|flagreportviewids" android:canretrievewindowcontent="true" android:canrequesttouchexplorationmode="true" android:packagenames="com.whatsapp" android:accessibilityfeedbacktype="feedbackspoken" android:notificationtimeout="500" /> 

notably, however, miss events. so, if you're relying on keeping in sync events, want se lower. it's balancing act.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -