Skip to content Skip to sidebar Skip to footer

Why Does Event.getsource() Return Null For Accessibility Events That Have A Related Source View?

For the event TYPE_VIEW_CLICKED on android.widget.Button the event.getSource() method return null. Ideally, this event should have a source attached. Also from Android API 18 onwa

Solution 1:

I faced with the same problem and it is solved by setting notificationTimeout to 100. Sample code is below:

protected void onServiceConnected() {
    super.onServiceConnected();
    AccessibilityServiceInfo info   = new AccessibilityServiceInfo();
    info.packageNames               = new String[]{getApplicationContext().getPackageName()};
    info.eventTypes                 = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType               = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
    info.notificationTimeout        = 100;
    info.flags                      = AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
    setServiceInfo(info);
}

Post a Comment for "Why Does Event.getsource() Return Null For Accessibility Events That Have A Related Source View?"