Skip to main content
Logo Appt Light

Input cancellation on Android

Users should be able to cancel accidental interaction. For example, when users accidentally touches the wrong button, they should be able to undo this and avoid performing an action. Accidental interaction is more common for people with various disabilities.

On Android, you should avoid using the ACTION_DOWN event of OnTouchListener, because users will not be able to cancel their interaction. Actions should only be activated through an ACTION_UP event. Use an OnClickListener instead, because it has built-in support for cancellation.

webView.setOnTouchListener { _, event ->
    if (event == MotionEvent.ACTION_DOWN) {
        // Use OnClickListener instead
    }
}

Feedback?

Let us know!