Code example for AccessibilityManager

Methods: isEnabled, isTouchExplorationEnabled

0
 
    @Override 
    public boolean onHoverEvent(MotionEvent event) {
        // When touch exploration is turned on, lifting a finger while inside 
        // the button's hover target bounds should perform a click action. 
        if (mAccessibilityManager.isEnabled()
                && mAccessibilityManager.isTouchExplorationEnabled()) {
            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    // Lift-to-type temporarily disables double-tap activation. 
                    setClickable(false);
                    break; 
                case MotionEvent.ACTION_HOVER_EXIT:
                    if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) {
                        simulateClickForAccessibility(); 
                    } 
                    setClickable(true);
                    break; 
            } 
        }