WatchFace.TapListener

interface WatchFace.TapListener


Listens for taps on the watchface.

Summary

Public methods

abstract @UiThread void
onTapEvent(
    @TapType int tapType,
    TapEvent tapEvent,
    ComplicationSlot complicationSlot
)

Called whenever the user taps on the watchface.

Public methods

onTapEvent

@UiThread
abstract void onTapEvent(
    @TapType int tapType,
    TapEvent tapEvent,
    ComplicationSlot complicationSlot
)

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.

Note there is a framework limitation preventing new activities from being launched by background process such as the watch face for 5 seconds after the home button has been pressed. If you need to send intents in response to taps it is recommended to use PendingIntentTapListener instead.

Parameters
@TapType int tapType

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