androidgesturestalkbackaccessibility

Gestures in Android Talkback


There are many gestures assigned in Talk-back. For instance all the L- gestures such as

I learnt that we can assign these gestures to different actions in Talk-back settings. But can we assign them to different actions programatically? Is it possible to create new gestures similar to them?


Solution

  • Accessibility services have a method that allows you to detect these gestures. Override it, no need to create new gestures at all!

    class YourService extends AccessibilityService {
        @Override
        public boolean onGesture(int gestureId) {
            switch (gestureId) {
                case GESTURE_SWIPE_LEFT_AND_RIGHT:
                    doStuff();
                    return true;
    
                default:
                    return false;
            }
        }
    }