Java Code Examples for android.text.TextUtils.SimpleStringSplitter

The following are Jave code examples for showing how to use SimpleStringSplitter of the android.text.TextUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: https-github.com-hyb1996-NoRootScriptDroid   File: AccessibilityServiceUtils.java   View Source Code Vote up 6 votes
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    ComponentName expectedComponentName = new ComponentName(context, accessibilityService);

    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null)
        return false;

    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);

    while (colonSplitter.hasNext()) {
        String componentNameString = colonSplitter.next();
        ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);

        if (enabledService != null && enabledService.equals(expectedComponentName))
            return true;
    }

    return false;
}
 
Example 2
Project: ViewDebugHelper   File: AccessibilityServiceHelper.java   View Source Code Vote up 6 votes
public static boolean isAccessibilitySettingsOn(Context context, String serviceName) {
    int accessibilityEnabled = 0;
    boolean accessibilityFound = false;
    try {
        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;
                }
            }
        }
    } else {
        // Log.v(TAG, "***ACCESSIBILIY IS DISABLED***");
    }

    return accessibilityFound;
}
 
Example 3
Project: Auto.js   File: AccessibilityServiceUtils.java   View Source Code Vote up 6 votes
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    ComponentName expectedComponentName = new ComponentName(context, accessibilityService);

    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null)
        return false;

    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);

    while (colonSplitter.hasNext()) {
        String componentNameString = colonSplitter.next();
        ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);

        if (enabledService != null && enabledService.equals(expectedComponentName))
            return true;
    }

    return false;
}
 
Example 4
Project: sao   File: MainActivity.java   View Source Code Vote up 6 votes
private boolean isAccessibilitySettingsOn() {
    int accessibilityEnabled = 0;
    final String service = getPackageName() + "/" + NotificationService.class.getName();
    boolean accessibilityFound = false;
    try {
        accessibilityEnabled = Settings.Secure.getInt(getApplicationContext().getContentResolver(), android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (Settings.SettingNotFoundException e) {
    }
    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
    if (accessibilityEnabled == 1) {
        String settingValue = Settings.Secure.getString(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(service)) {
                    return true;
                }
            }
        }
    } else {
    }

    return accessibilityFound;
}
 
Example 5
Project: TPlayer   File: AceHelper.java   View Source Code Vote up 6 votes
/**
 * 检测当前辅助服务是否开启
 */
public static boolean checkAccessibilityEnabled(Context context,Class<? extends AccessibilityService> clazz) {
    int accessibilityEnabled = 0;
    final String service = context.getPackageName() + "/" + clazz.getCanonicalName();
    try {
        accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (Settings.SettingNotFoundException ignored) {
        // ignored
    }
    TextUtils.SimpleStringSplitter stringColonSplitter = new TextUtils.SimpleStringSplitter(':');
    if (accessibilityEnabled == 1) {
        String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (settingValue != null) {
            stringColonSplitter.setString(settingValue);
            while (stringColonSplitter.hasNext()) {
                String accessibilityService = stringColonSplitter.next();
                if (accessibilityService.equalsIgnoreCase(service)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 6
Project: Accessibility   File: AccessibilityUtils.java   View Source Code Vote up 6 votes
public static void getAccessibilityStatus(Context context) {
    long start = System.currentTimeMillis();
    try {
        Set<ComponentName> enabledServices = new HashSet<>();
        final String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        final TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
        colonSplitter.setString(enabledServicesSetting);
        while (colonSplitter.hasNext()) {
            final String componentNameString = colonSplitter.next();
            final ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);
            BaseAccessibility.logPrint("getAccessibilityStatus= " + componentNameString + "  enabledService=" + (enabledService == null ? false : true));
            if (enabledService != null) {
                enabledServices.add(enabledService);
            }
        }
        ComponentName appstoreComponent = new ComponentName(context, MyAccessibility.class);
        BaseAccessibility.isEnable.set(enabledServices.contains(appstoreComponent));
        BaseAccessibility.logPrint("getAccessibilityStatus status:" + BaseAccessibility.isEnable.get() + "  enabledServicesSetting=" + enabledServicesSetting);
    } catch (Throwable e) {
        BaseAccessibility.logPrint(e.getMessage());
        e.printStackTrace();
    }
    BaseAccessibility.logPrint("getAccessibilityStatus= " + "getAccessibilityStatus cost:" + (System.currentTimeMillis() - start) + ",status:" + BaseAccessibility.isEnable.get());
}
 
Example 7
Project: financisto1-holo   File: QifExportActivity.java   View Source Code Vote up 6 votes
private void parseSelectedAccounts(String selectedIds) {
    try {
        TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
        splitter.setString(selectedIds);
        for (String s : splitter) {
            long id = Long.parseLong(s);
            for (Account account : accounts) {
                if (account.id == id) {
                    account.setChecked(true);
                    break;
                }
            }
        }
    } catch (Exception ex) {
        // ignore
    }
}
 
Example 8
Project: NotifyTools   File: JumpService.java   View Source Code Vote up 5 votes
private boolean isAccessibilitySettingsOn(Context mContext) {
    int accessibilityEnabled = 0;
    final String service = getPackageName() + "/" + JumpService.class.getCanonicalName();
    try {
        accessibilityEnabled = Settings.Secure.getInt(
                mContext.getApplicationContext().getContentResolver(),
                android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
        log.v( "accessibilityEnabled = " + accessibilityEnabled);
    } catch (Settings.SettingNotFoundException e) {
        log.d( "Error finding setting, default accessibility to not found: "
                + e.getMessage());
    }
    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');

    if (accessibilityEnabled == 1) {
        log.v( "***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( "-------------- > accessibilityService :: " + accessibilityService + " " + service);
                if (accessibilityService.equalsIgnoreCase(service)) {
                    log.v( "We've found the correct setting - accessibility is switched on!");
                    return true;
                }
            }
        }
    } else {
        log.v( "***ACCESSIBILITY IS DISABLED***");
    }

    return false;
}
 
Example 9
Project: NotifyTools   File: ForceStopActivity.java   View Source Code Vote up 5 votes
private boolean isAccessibilitySettingsOn(Context mContext) {
    int accessibilityEnabled = 0;
    final String service = getPackageName() + "/" + HelpService.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;
}
 
Example 10
Project: Forge   File: Util.java   View Source Code Vote up 5 votes
/**
 * Checks if the Forge Auto fill accessibility service is enabled
 *
 * @param context application context
 * @return true = service enabled, false = service disabled
 */
public static boolean isAccessibilitySettingsOn(Context context) {
    int accessibilityEnabled = 0;
    final String service = context.getPackageName() + "/" + AccessibilityAutofillService.class.getCanonicalName();
    try {
        accessibilityEnabled = Settings.Secure.getInt(
                context.getApplicationContext().getContentResolver(),
                android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
    } catch (Settings.SettingNotFoundException e) {
        // If there is an error, log it
        Log.e(Forge.ERROR_LOG, e.getMessage());
    }
    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) {
            mStringColonSplitter.setString(settingValue);
            while (mStringColonSplitter.hasNext()) {
                String accessibilityService = mStringColonSplitter.next();

                if (accessibilityService.equalsIgnoreCase(service)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 11
Project: CurrentActivity   File: AccessibilityServiceUtils.java   View Source Code Vote up 5 votes
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
    String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
    if (enabledServicesSetting == null) return false;
    TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
    colonSplitter.setString(enabledServicesSetting);
    while (colonSplitter.hasNext()) {
        ComponentName enabledService = ComponentName.unflattenFromString(colonSplitter.next());
        if (enabledService != null && enabledService.equals(new ComponentName(context, accessibilityService)))
            return true;
    }
    return false;
}
 
Example 12
Project: Bigbang   File: BigBangMonitorService.java   View Source Code Vote up 5 votes
public static boolean isAccessibilitySettingsOn(Context mContext) {
    int accessibilityEnabled = 0;
    final String service = BigBangApp.getInstance().getPackageName() + "/" + BigBangMonitorService.class.getCanonicalName();
    try {
        accessibilityEnabled = Settings.Secure.getInt(
                mContext.getApplicationContext().getContentResolver(),
                android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
        LogUtil.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
    } catch (Settings.SettingNotFoundException e) {
        LogUtil.d(TAG, "Error finding setting, default accessibility to not found: "
                + e.getMessage());
    }
    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');

    if (accessibilityEnabled == 1) {
        LogUtil.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();

                LogUtil.v(TAG, "-------------- > accessibilityService :: " + accessibilityService + " " + service);
                if (accessibilityService.equalsIgnoreCase(service)) {
                    LogUtil.v(TAG, "We've found the correct setting - accessibility is switched on!");
                    return true;
                }
            }
        }
    } else {
        LogUtil.v(TAG, "***ACCESSIBILITY IS DISABLED***");
    }

    return false;
}
 
Example 13
Project: FreshMember   File: MainActivity.java   View Source Code Vote up 5 votes
private boolean isAccessibilitySettingsOn(Context mContext) {
    int accessibilityEnabled = 0;
    final String service = getPackageName() + "/" + getPackageName() + ".MyService";
    boolean accessibilityFound = false;
    try {
        accessibilityEnabled = Settings.Secure.getInt(
                mContext.getApplicationContext().getContentResolver(),
                Settings.Secure.ACCESSIBILITY_ENABLED);
        Log.v("MainActivity","accessibilityEnabled = " + accessibilityEnabled);
    } catch (Settings.SettingNotFoundException e) {
        Log.e("MainActivity","Error finding setting, default accessibility to not found: "
                + e.getMessage());
    }
    TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');

    if (accessibilityEnabled == 1) {
        Log.v("MainActivity","***ACCESSIBILIY IS ENABLED*** -----------------");
        String settingValue = Settings.Secure.getString(
                mContext.getApplicationContext().getContentResolver(),
                Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
        if (settingValue != null) {
            TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
            splitter.setString(settingValue);
            while (splitter.hasNext()) {
                String accessabilityService = splitter.next();

                Log.v("MainActivity","-------------- > accessabilityService :: " + accessabilityService);
                if (accessabilityService.equalsIgnoreCase(service)) {
                    Log.v("MainActivity","We've found the correct setting - accessibility is switched on!");
                    return true;
                }
            }
        }
    } else {
        Log.v("MainActivity","***ACCESSIBILIY IS DISABLED***");
    }
    return accessibilityFound;
}