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.

1 Answer 1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.