Example usage for android.accessibilityservice AccessibilityServiceInfo getId

List of usage examples for android.accessibilityservice AccessibilityServiceInfo getId

Introduction

In this page you can find the example usage for android.accessibilityservice AccessibilityServiceInfo getId.

Prototype

public String getId() 

Source Link

Document

The accessibility service id.

Usage

From source file:Main.java

public static boolean checkAccessibilityEnabled(Context context, String serviceName) {
    AccessibilityManager manager = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    List<AccessibilityServiceInfo> list = manager
            .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    for (AccessibilityServiceInfo accessibilityServiceInfo : list) {
        if (accessibilityServiceInfo.getId().equals(serviceName)) {
            return true;
        }/*from   w  ww .j av  a 2  s  .c o  m*/
    }
    return false;
}

From source file:com.odo.kcl.mobileminer.activities.MainActivity.java

private boolean isAccessibilityEnabled() {
    // http://stackoverflow.com/questions/5081145/android-how-do-you-check-if-a-particular-accessibilityservice-is-enabled
    if (Build.VERSION.SDK_INT >= 17) {
        AccessibilityManager am = (AccessibilityManager) this.getSystemService(Context.ACCESSIBILITY_SERVICE);
        List<AccessibilityServiceInfo> runningServices = am
                .getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);
        for (AccessibilityServiceInfo service : runningServices) {
            if ("com.odo.kcl.mobileminer/.NotificationService".equals(service.getId()))
                return true;
        }//w w  w . j av  a2s .c o m
    }
    return false;
}