GestureProducer

interface GestureProducer


Defines the contract for a component that produces gesture events from a hardware or software source managed by the developer.

Implement this interface to bridge your external device's events, such as from a connected ring, earbuds, or watch, into the Google Play services Remote Gestures ecosystem. The SDK handles the producer lifecycle automatically.

Summary

Public functions

Unit

Registers a callback to be notified when the availability of gestures changes.

Unit
registerGestureEventListener(
    params: GestureRegistrationParams,
    executor: Executor,
    listener: GestureEventListener
)

Receives a signal when Google Play services is ready to receive gestures from this producer.

Unit

Unregisters a previously added availability change listener.

Unit

Receives a signal when Google Play services no longer needs events from this producer.

Public functions

registerAvailabilityChangeListener

fun registerAvailabilityChangeListener(
    executor: Executor,
    listener: Consumer<DeviceGestureCapability!>
): Unit

Registers a callback to be notified when the availability of gestures changes.

Important: You must immediately invoke the provided listener on registration with the current availability state, in addition to invoking it whenever the availability changes.

Parameters
executor: Executor

The executor on which the listener should be invoked.

listener: Consumer<DeviceGestureCapability!>

The callback that receives the updated availability.

registerGestureEventListener

fun registerGestureEventListener(
    params: GestureRegistrationParams,
    executor: Executor,
    listener: GestureEventListener
): Unit

Receives a signal when Google Play services is ready to receive gestures from this producer.

On receiving this call, you should begin emitting GestureEvent objects that match the requested actions to the provided listener.

Note: The client library automatically filters out and drops any events that don't match the currently requested actions to save IPC bandwidth. However, to conserve battery and system resources, you should still strive to avoid generating unrequested events internally.

Parameters
params: GestureRegistrationParams

Configuration specifying which gesture actions, such as GestureEvent.ACTION_PRIMARY, that Google Play services is currently requesting.

executor: Executor

The executor on which the listener callbacks should be invoked.

listener: GestureEventListener

The target listener that receives the injected events.

unregisterAvailabilityChangeListener

fun unregisterAvailabilityChangeListener(
    listener: Consumer<DeviceGestureCapability!>
): Unit

Unregisters a previously added availability change listener.

Parameters
listener: Consumer<DeviceGestureCapability!>

The listener to remove.

unregisterGestureEventListener

fun unregisterGestureEventListener(listener: GestureEventListener): Unit

Receives a signal when Google Play services no longer needs events from this producer.

You should stop sending events to the specified listener to conserve resources.

Parameters
listener: GestureEventListener

The listener that should be unregistered.