WatchFace.TapListener

interface WatchFace.TapListener


Listens for taps on the watchface.

Summary

Public functions

Unit
@UiThread
onTapEvent(
    tapType: Int,
    tapEvent: TapEvent,
    complicationSlot: ComplicationSlot?
)

Called whenever the user taps on the watchface.

Public functions

onTapEvent

Added in 1.0.0
@UiThread
fun onTapEvent(
    tapType: Int,
    tapEvent: TapEvent,
    complicationSlot: ComplicationSlot?
): Unit

Called whenever the user taps on the watchface.

The watch face receives three different types of touch events:

  • TapType.DOWN when the user puts the finger down on the touchscreen

  • TapType.UP when the user lifts the finger from the touchscreen

  • TapType.CANCEL when the system detects that the user is performing a gesture other than a tap

Note that the watch face is only given tap events, i.e., events where the user puts the finger down on the screen and then lifts it at the position. If the user performs any other type of gesture while their finger in on the touchscreen, the watch face will be receive a cancel, as all other gestures are reserved by the system.

Therefore, a TapType.DOWN event and the successive TapType.UP event are guaranteed to be close enough to be considered a tap according to the value returned by android.view.ViewConfiguration.getScaledTouchSlop.

If the watch face receives a TapType.CANCEL event, it should not trigger any action, as the system is already processing the gesture.

Parameters
tapType: Int

The type of touch event sent to the watch face

tapEvent: TapEvent

The received TapEvent

complicationSlot: ComplicationSlot?

The ComplicationSlot tapped if any or null otherwise