title: Why onAccessibilityEvent(..) method of AccessibilityService is reading the same view many times?
body: <p>I am using AccessibilityService to determine the text and coordinates of views of any current application running in android device.
  On every event onAccessibilityEvent(...) runs but i don't know how to control these events. I have used event.getSource() to get the result of every window content changed. The xml settings of my AccessibilityService is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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"
  
  /&gt;
  </code></pre>
  
  <p>and the onAccessibilityEvent(...) is:</p>
  
  <pre><code>@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);
  
  
      }
  </code></pre>
  
  <p>and the output which i am getting is(I have highlighted the text value in bold:</p>
  
  <pre><code>08-18 19:34:29.055 20131-20131/com.example.root.without_root E/MyService:: Get 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:: Get 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:: Get 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:: Get 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]
  </code></pre>
  
  <p>Now you can see that it ran 3 times for only 1 view But i want it to run only for single time for one view. Please help me to find out how can i make this possible?</p>
  
  <p>I have already tried with changing the values of accessibilityEventTypes in xml from "typeAllMasks" to "typeWindowContentChanged" and "typeViewFocused" but nothing helped me out.</p>
  
  <p>I have also tried to setup flags in onAccessibilityEvent(...) of AccessibilityService but that also didn't worked because the service keeps on running everytime(It would be great if somebody can make it work).</p>
  
  <p>Please do tell me how can i make it to work!</p>