Java tutorial
//package com.java2s; //License from project: Creative Commons License import android.accessibilityservice.AccessibilityService; import android.content.ComponentName; import android.content.Context; import android.provider.Settings; import android.text.TextUtils; public class Main { public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> 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(':'); colonSplitter.setString(enabledServicesSetting); while (colonSplitter.hasNext()) { String componentNameString = colonSplitter.next(); ComponentName enabledService = ComponentName.unflattenFromString(componentNameString); if (enabledService != null && enabledService.equals(expectedComponentName)) return true; } return false; } }