Android:如何检查是否启用了特定的AccessibilityService

我写了一个Android应用程序,需要使用AccessibilityService。
我知道如何检查手机上是否启用辅助功能,但我无法确定是否在无障碍功能菜单中特别启用了我的应用。

我想提示用户,如果AccessibilityService没有运行,但是找不到一个好的方法这样做。
是否有任何我可能会缺少的API方法,让我知道哪些辅助功能服务在设备上启用?

我最后自己完成了这个:

    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;
             splitter.setString(settingValue);
             while (splitter.hasNext()) {
                 String accessabilityService = splitter.next();
                 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***");
    }
    else{
        Log.d(LOGTAG, "***ACCESSIBILIY IS DISABLED***");
    }
    return accessibilityFound;
}
http://stackoverflow.com/questions/5081145/android-how-do-you-check-if-a-particular-accessibilityservice-is-enabled

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:Android:如何检查是否启用了特定的AccessibilityService