is Accessibility Settings On - Android User Interface

Android examples for User Interface:AccessibilityEvent

Description

is Accessibility Settings On

Demo Code


//package com.java2s;
import android.content.Context;

import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;

public class Main {
    public static boolean isAccessibilitySettingsOn(Context context,
            String serviceName) {
        int accessibilityEnabled = 0;
        boolean accessibilityFound = false;
        try {/*from   www  .jav  a 2  s.  co m*/
            accessibilityEnabled = Settings.Secure.getInt(context
                    .getApplicationContext().getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_ENABLED);
        } catch (SettingNotFoundException e) {
        }
        TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(
                ':');
        if (accessibilityEnabled == 1) {
            String settingValue = Settings.Secure.getString(context
                    .getApplicationContext().getContentResolver(),
                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
            if (settingValue != null) {
                TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
                splitter.setString(settingValue);
                while (splitter.hasNext()) {
                    String accessabilityService = splitter.next();
                    if (accessabilityService.equalsIgnoreCase(serviceName)) {
                        return true;
                    }
                }
            }
        } 

        return accessibilityFound;
    }
}

Related Tutorials