// To check if service is enabledprivate boolean isAccessibilitySettingsOn(Context mContext) {    int accessibilityEnabled = 0;    final String service = getPackageName() + "/" + YOURAccessibilityService.class.getCanonicalName();    try {        accessibilityEnabled = Settings.Secure.getInt(                mContext.getApplicationContext().getContentResolver(),                android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);        Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);    } catch (Settings.SettingNotFoundException e) {        Log.e(TAG, "Error finding setting, default accessibility to not found: "                + e.getMessage());    }    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');    if (accessibilityEnabled == 1) {        Log.v(TAG, "***ACCESSIBILITY IS ENABLED*** -----------------");        String settingValue = Settings.Secure.getString(                mContext.getApplicationContext().getContentResolver(),                Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);        if (settingValue != null) {            mStringColonSplitter.setString(settingValue);            while (mStringColonSplitter.hasNext()) {                String accessibilityService = mStringColonSplitter.next();                Log.v(TAG, "-------------- > accessibilityService :: " + accessibilityService + " " + service);                if (accessibilityService.equalsIgnoreCase(service)) {                    Log.v(TAG, "We've found the correct setting - accessibility is switched on!");                    return true;                }            }        }    } else {        Log.v(TAG, "***ACCESSIBILITY IS DISABLED***");    }    return false;}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. linux的常用命令
  2. linux安装PHP环境
  3. Linux 安装MongoDB 2.6.5
  4. Linux运维:安装CentOS7.2-图解
  5. 在Linux和FreeBSD之间移植bash脚本的正确
  6. 用VXE保护Linux系统安全
  7. 学习linux几本不错的书
  8. linux设置时间和把时间从UTC转成本地时间
  9. mysqk 5.7官方安装指导,比一般有效
  10. Linux&C网络编程————“聊天室”