3

My code works fine with Android versions above 4 but in Android 2.2 or 2.3 I am unable to detect Any event. Android logs show that service is running but whenever I fire a event its not recognized by Accessibility service. In following code :

public void onAccessibilityEvent(AccessibilityEvent event)
{       
    Log.i("abc","------service running---------");

    final int eventType = event.getEventType();

    switch(eventType)
    {
        case AccessibilityEvent.TYPE_VIEW_CLICKED :
                //do something
                break;
        }
}

I am not able to get Log "------service running---------" also. What am I missing. Is there any changes needed to be made to run the same code on different versions of android.

rds
  • 26,253
  • 19
  • 107
  • 134
Aduait Pokhriyal
  • 1,529
  • 14
  • 30

1 Answers1

0

You will need to manually specify your service's event and feedback types by setting your service's AccessibilityServiceInfo in onServiceConnected().

Here is an example from TalkBack:

@Override
public void onServiceConnected() {
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
    info.notificationTimeout = 0;
    info.flags = AccessibilityServiceInfo.DEFAULT;
    setServiceInfo(info);
}
alanv
  • 23,966
  • 4
  • 93
  • 80