Search code examples
androidtouchlistenergesture

Android: How can I know a confirmed single tap has ended?


I want to know when a confirmed single tap has ended.

The onSingleTapUp in GestureDetector.SimpleOnGestureListener occurs before onSingleTapConfirmed.

How can I know if a confirmed single tap has finished?


Solution

  • onSingleTapConfirmed() is your check of confidence that the single tap has finished. The linked javadoc will help you understand the difference between that an onSingleTapUp():

    Unlike onSingleTapUp(MotionEvent), this will only be called after the detector is confident that the user's first tap is not followed by a second tap leading to a double-tap gesture.

    In other words, you can be certain at this point that the next touch down is not going to be starting a double-tap, because it exceeded whatever the delay Android allows between taps to count as a full double-tap.