I have an Android AccessibilityService
deployed to a Samsung Note 4 running Android 5.0.1.
I'm using WhatsApp as a test bed, but this applies to any Application and is more a question around how the Accessibility Service fires off events.
The event 2048 (TYPE_WINDOW_CONTENT_CHANGED)
is not consistent fired by Android. If I send messages to my WhatsApp with it in focus and the screen on 75% of the time this event is fired and at times is simply doesn't.
Is there a reason for this? Are Accessibility events not dependendable..?
Additionally, it appears that the event 4096 (TYPE_VIEW_SCROLLED)
does get fired consistently when the user scrolls or when new correspondence appear in WhatsApps' chat window however, there doesn't seem to be anyway to determine what the current scroll position of the device is? AccessibilityEvent.getSource()
provides access to some meta-data for the list (in this case android:id/list) however there is no information available as to the scroll position of this list or its children elements. The child list is relative to what is displayed on the screen and the boundsToScreen/Parent
values are the same regardless if you're looking at the bottom of the list or the middle or top. Is there any clues to help me determine the scroll position from the AccessibilityEventNodeInfo
instance I am presented with?
Lastly, when the 2048 (TYPE_WINDOW_CONTENT_CHANGED)
event does fire, there are times when the new elements are not actually available from the AccessibiltyEvent.getSource()
(even when you iterate up to the root element vi a while loop using getParent()
and then scan down again). It appears that the event is taking a snapshot of the screen before the change has been applied to the UI. A thread.sleep
does not help - as it appears the AccessibilityEventNodeInfo
is more of a snapshot than live access to the UI? Any way around this?