android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat Java Examples

The following examples show how to use android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccessibilityManagerSupportActivity.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
/**
 * Updates the content of a TextView with description of the enabled
 * accessibility services.
 */
private void updateAccessibilityStateView() {
    // The API for getting the enabled accessibility services based on feedback
    // type was added in ICS. Therefore to be backwards compatible we use the
    // APIs in the support library. Note that if the platform API version is lower
    // and the called API is not available an empty list of services is returned.
    List<AccessibilityServiceInfo> enabledServices =
        AccessibilityManagerCompat.getEnabledAccessibilityServiceList(mAccessibilityManager,
                AccessibilityServiceInfo.FEEDBACK_SPOKEN);
    if (!enabledServices.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        final int enabledServiceCount = enabledServices.size();
        for (int i = 0; i < enabledServiceCount; i++) {
            AccessibilityServiceInfo service = enabledServices.get(i);
            // Some new APIs were added in ICS for getting more information about
            // an accessibility service. Again accessed them via the support library.
            ResolveInfo resolveInfo = AccessibilityServiceInfoCompat.getResolveInfo(service);
            String serviceDescription = getString(
                    R.string.accessibility_manager_enabled_service,
                    resolveInfo.loadLabel(getPackageManager()),
                    AccessibilityServiceInfoCompat.feedbackTypeToString(service.feedbackType),
                    AccessibilityServiceInfoCompat.getDescription(service),
                    AccessibilityServiceInfoCompat.getSettingsActivityName(service));
            builder.append(serviceDescription);
        }
        mAccessibilityStateView.setText(builder);
    } else {
        // Either no services or the platform API version is not high enough.
        mAccessibilityStateView.setText(getString(
                R.string.accessibility_manager_no_enabled_services));
    }
}