Exemple #1
0
 /**
  * Registers an AccessibilityStateChangeListener that show a Toast
  * when the global accessibility state on the device changes.
  */
 private void RegisterAccessibilityStateChangeListener()
 {
     // The AccessibilityStateChange listener APIs were 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 no listener
     // is Added and you will not receive a call of onAccessibilityStateChanged.
     AccessibilityManagerCompat.AddAccessibilityStateChangeListener(mAccessibilityManager,
                                                                    new MyAccessibilityStateChangeListenerCompat(this));
 }
Exemple #2
0
        /**
         * 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.
            IList <AccessibilityServiceInfo> enabledServices =
                AccessibilityManagerCompat.GetEnabledAccessibilityServiceList(mAccessibilityManager,
                                                                              AccessibilityServiceInfo.FEEDBACK_SPOKEN);

            if (!enabledServices.IsEmpty())
            {
                StringBuilder builder             = new StringBuilder();
                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.Text = (builder);
            }
            else
            {
                // Either no services or the platform API version is not high enough.
                mAccessibilityStateView.Text = (GetString(
                                                    R.String.accessibility_manager_no_enabled_services));
            }
        }