Android: How do you check if a particular AccessibilityService is enabled

I’ve written an android app that requires the use of the AccessibilityService.
I know how to check to see if Accessibility is enabled or disabled on the phone, but I cannot work out a way to determine if my app has been specifically enabled within the accessibility menu.

I’m wanting to prompt the user if the AccessibilityService is not running, but can’t find a good way of doing this.
Is there any API methods that I might be missing that would let me know which accessibility services are enabled on the device?

  • Abrupt scrolling with NestedScrollView in ViewPager Fragment inside a CoordinatorLayout Android
  • Camera Preview black in Android 7
  • Parse notifications on android won't work
  • Android best way to get location repeatedly in background considering battery as well
  • How to cache/save custom class object in Android?
  • You uploaded an APK that is not zip aligned error
  • Related posts:

    Toolbar in DialogFragment
    Is it possible to get the “Popular times” information through the Google Places ...
    How to deal with Android devices that do not honor EXIF orientation data?
    Static singleton lifetime in Android
    Does Google Play In-App Billing Version 3 support refunds?
    Android Studio. Drawables folder and sizes?
  • Internet usage(Data usage) by WebView
  • View animation right to left android
  • setvisibility(view.visible) not working after setvisibility(view.gone)
  • Is there anyway to swap or reorder fragment BackStack entry?
  • ZBar - QR Code Scanner, crashing in Android Studio
  • How to disable android map marker click auto center
  • 7 Solutions collect form web for “Android: How do you check if a particular AccessibilityService is enabled”

    I worked this one out myself in the end:

        public boolean isAccessibilityEnabled(){
        int accessibilityEnabled = 0;
        final String LIGHTFLOW_ACCESSIBILITY_SERVICE = "com.example.test/com.example.text.ccessibilityService";
        boolean accessibilityFound = false;
        try {
            accessibilityEnabled = Settings.Secure.getInt(this.getContentResolver(),android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
            Log.d(LOGTAG, "ACCESSIBILITY: " + accessibilityEnabled);
        } catch (SettingNotFoundException e) {
            Log.d(LOGTAG, "Error finding setting, default accessibility to not found: " + e.getMessage());
        TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
        if (accessibilityEnabled==1){
            Log.d(LOGTAG, "***ACCESSIBILIY IS ENABLED***: ");
             String settingValue = Settings.Secure.getString(getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
             Log.d(LOGTAG, "Setting: " + settingValue);
             if (settingValue != null) {
                 TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
                 while (splitter.hasNext()) {
                     String accessabilityService =;
                     Log.d(LOGTAG, "Setting: " + accessabilityService);
                     if (accessabilityService.equalsIgnoreCase(ACCESSIBILITY_SERVICE_NAME)){
                         Log.d(LOGTAG, "We've found the correct setting - accessibility is switched on!");
                         return true;
            Log.d(LOGTAG, "***END***");
            Log.d(LOGTAG, "***ACCESSIBILIY IS DISABLED***");
        return accessibilityFound;

    Since API Level 14, it is also possible to obtain the running accessibility services through the AccessibilityManager:

    public static boolean isAccessibilityEnabled(Context context, String id) {
        AccessibilityManager am = (AccessibilityManager) context
        List<AccessibilityServiceInfo> runningServices = am
        for (AccessibilityServiceInfo service : runningServices) {
            if (id.equals(service.getId())) {
                return true;
        return false;

    To find out the ID of your and all the installed accessibility services, you can run the following code snippet:

    public static void logInstalledAccessiblityServices(Context context) {
        AccessibilityManager am = (AccessibilityManager) context
        List<AccessibilityServiceInfo> runningServices = am
        for (AccessibilityServiceInfo service : runningServices) {
            Log.i(TAG, service.getId());

    In my example, the ID looked like org.your.package/.YourAccessibilityService.

    So far, the method worked reliable.

    Can you just keep track of whether the service is running like this? If the accessibility service is enabled shouldn’t it also be running??

    public class MyAccessibilityService extends AccessibilityService{
    public static boolean isEnabled = false; 
        public void onServiceConnected() {
          isEnabled = true; 
        public void onDestroy(){ 
          isEnabled = false; 

    Checking if the service is enabled

     * Based on {@link,int)}
     * @see <a href="">AccessibilityUtils</a>
    public static boolean isAccessibilityServiceEnabled(Context context, Class<?> accessibilityService) {
        ComponentName expectedComponentName = new ComponentName(context, accessibilityService);
        String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(),  Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (enabledServicesSetting == null)
            return false;
        TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
        while (colonSplitter.hasNext()) {
            String componentNameString =;
            ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);
            if (enabledService != null && enabledService.equals(expectedComponentName))
                return true;
        return false;


    boolean enabled = isAccessibilityServiceEnabled(context, MyAccessibilityService.class);

    Detecting when the service is enabled or disabled

    Make a callback:

    ContentObserver observer = new ContentObserver() {
        public void onChange(boolean selfChange) {
            boolean accessibilityServiceEnabled = isAccessibilityServiceEnabled(context, MyAccessibilityService.class);
            //Do something here


    context.getContentResolver().registerContentObserver(uri, false, observer);

    Unsubscribe when you’re done:


    Note that this doesn’t work with the getEnabledAccessibilityServiceList() approach since its values were out-of-sync with the Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES values. That’s why I think using Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES is a better one-size-fits-all approach.

    Get the ID when your activity service just started.
    In your Activity service OnSeriviceCeonnected after all the initialize calls. Use this…

    AccessibilityServiceInfo serviceInfo = this.getServiceInfo();
        String accessibilityId = serviceInfo.getId();

    Requires Jelly Bean API

    Then you can use Martin’s code (isAccessibilityEnabled) to check running services.

    this need more times

    AccessibilityManager am = (AccessibilityManager) context
     AccessibilityManager accessibilityManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE);
            List<AccessibilityServiceInfo> runningservice = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
            accessibilityManager.addAccessibilityStateChangeListener(new AccessibilityManager.AccessibilityStateChangeListener() {
                public void onAccessibilityStateChanged(boolean b) {
                    Toast.makeText(MainActivity.this, "permission "+b, Toast.LENGTH_SHORT).show();

    Listner will be called whenever state is changed
    you can keep track of the boolean to check the permission
    this is by far the simplest and lightest solution to check permission

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.