Example usage for android.content Context ACCESSIBILITY_SERVICE

List of usage examples for android.content Context ACCESSIBILITY_SERVICE

Introduction

In this page you can find the example usage for android.content Context ACCESSIBILITY_SERVICE.

Prototype

String ACCESSIBILITY_SERVICE

To view the source code for android.content Context ACCESSIBILITY_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.accessibility.AccessibilityManager for giving the user feedback for UI events through the registered event listeners.

Usage

From source file:Main.java

public static boolean checkAccessibilityEnabled(Context context, String serviceName) {
    AccessibilityManager manager = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    List<AccessibilityServiceInfo> list = manager
            .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    for (AccessibilityServiceInfo accessibilityServiceInfo : list) {
        if (accessibilityServiceInfo.getId().equals(serviceName)) {
            return true;
        }/*from  ww  w  . ja  v a  2 s  .c o m*/
    }
    return false;
}

From source file:Main.java

public static boolean isEnable(Context context) {
    AccessibilityManager manager = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    List<AccessibilityServiceInfo> services = manager
            .getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    boolean flag = false;
    for (AccessibilityServiceInfo info : services) {
        ResolveInfo i = info.getResolveInfo();
        if (TextUtils.equals(context.getPackageName(), i.serviceInfo.packageName)) {
            flag = true;/*  w  w w .  jav  a  2s.  c  om*/
            break;
        }
    }
    return flag;
}

From source file:Main.java

public static boolean isAccessibilityEnabled(Context context) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    return accessibilityManager.isTouchExplorationEnabled();
}

From source file:Main.java

/**
 * Return true if the accessibility service or touch exploration are enabled.
 *//*from w ww.  j a va  2 s  .  com*/
public static boolean isTouchAccessiblityEnabled(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    boolean isAccessibilityEnabled = am.isEnabled();
    boolean isTouchExplorationEnabled = am.isTouchExplorationEnabled();
    return isAccessibilityEnabled || isTouchExplorationEnabled;
}

From source file:Main.java

/**
 * If accessibility manager is enabled, we should force text views to be focusable.
 *//*  www  . j ava  2 s  .  co  m*/
public static boolean forceFocusableViews(Context context) {
    AccessibilityManager accessMan = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    return accessMan.isEnabled();
}

From source file:Main.java

public static AccessibilityManager getAccessibilityManager(Context context) {
    return (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:Main.java

public static boolean isTouchExplorationEnabled(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    return am.isTouchExplorationEnabled();
}

From source file:Main.java

public static void sendAccessibilityEvent(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isEnabled()) {
        am.sendAccessibilityEvent(AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED));
    }/*from  w  ww.  j a  v  a  2  s  . com*/
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static boolean isTouchExplorationEnabled(Context context) {
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    return am.isTouchExplorationEnabled();
}

From source file:Main.java

/**
 * Try to send an {@link AccessibilityEvent}
 * for a {@link View}.//from w  w  w. java2  s  .  c  o m
 *
 * @param view The View that will dispatch the AccessibilityEvent
 * @return true if the AccessibilityEvent was dispatched
 */
@SuppressWarnings("UnusedReturnValue")
public static boolean sendAccessibilityEvent(View view) {
    final AccessibilityManager accessibilityManager = (AccessibilityManager) view.getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (!accessibilityManager.isEnabled())
        return false;

    final AccessibilityEvent accessibilityEvent = AccessibilityEvent
            .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
    accessibilityEvent.setClassName(view.getClass().getName());
    accessibilityEvent.setPackageName(view.getContext().getPackageName());

    view.dispatchPopulateAccessibilityEvent(accessibilityEvent);
    accessibilityManager.sendAccessibilityEvent(accessibilityEvent);

    return true;
}