Accessibility action - Android

On Android, you can add custom actions for assistive technologies using the ViewCompat.addAccessibilityAction helper method.

You can also use the addAction method of AccessibilityNodeInfoCompat to override labels for default actions.

// Add custom action
ViewCompat.addAccessibilityAction(view, "Add bookmark") { view, arguments ->
    // Bookmark logic
    true
}

// Override click action label
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() {
    @Override
    public void onInitializeAccessibilityNodeInfo(
        View host,
        AccessibilityNodeInfoCompat info)
    {
        super.onInitializeAccessibilityNodeInfo(host, info)
        AccessibilityActionCompat action = new AccessibilityActionCompat(
            AccessibilityNodeInfoCompat.ACTION_CLICK,
            "Add bookmark"
        )
        info.addAction(action)
    }
})