Android的:你如何检查特定AccessibilityService启用 [英] Android: How do you check if a particular AccessibilityService is enabled

查看:1282
本文介绍了Android的:你如何检查特定AccessibilityService启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个Android应用程序,需要使用AccessibilityService的。 我知道如何检查是否启用了辅助功能,或在手机上被禁用,但我不能找出一个方法来确定是否我的应用程序也可访问菜单中专门启用。

I've written an android app that requires the use of the AccessibilityService. I know how to check to see if Accessibility is enabled or disabled on the phone, but I cannot work out a way to determine if my app has been specifically enabled within the accessibility menu.

我想提示如果AccessibilityService没有运行的用户,却找不到这样的好方法。 有没有办法,我可能会丢失,任何API方法将让我知道哪些辅助服务在设备上启用了?

I'm wanting to prompt the user if the AccessibilityService is not running, but can't find a good way of doing this. Is there any API methods that I might be missing that would let me know which accessibility services are enabled on the device?

推荐答案

我到底该工作出自己:

    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;
}

这篇关于Android的:你如何检查特定AccessibilityService启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆