Google is committed to advancing racial equity for Black communities. See how.

WatchFaceHostApi

interface WatchFaceHostApi
androidx.wear.watchface.WatchFaceHostApi

The API WatchFace uses to communicate with the system.

Summary

Public methods
abstract Context

Returns the watch face's Context.

abstract Handler

Returns the main thread Handler.

abstract UserStyleWireFormat?

Returns the initial user style stored by the system if there is one or null otherwise.

abstract Unit

Schedules a call to Renderer.renderInternal to draw the next frame.

abstract Unit
setActiveComplications(watchFaceComplicationIds: IntArray)

Sets the complications which are active in the watchface.

abstract Unit
setComplicationDetails(complicationId: Int, bounds: Rect, boundsType: Int, types: IntArray)

Registers details of the complications with the system.

abstract Unit
setContentDescriptionLabels(labels: Array<ContentDescriptionLabel>)

Sets ContentDescriptionLabels for text-to-speech screen readers to make your complications, buttons, and any other text on your watchface accessible.

abstract Unit
setCurrentUserStyle(userStyle: UserStyleWireFormat)

Registers the watch face's current user style with the system.

abstract Unit
setDefaultComplicationProviderWithFallbacks(watchFaceComplicationId: Int, providers: List<ComponentName>?, fallbackSystemProvider: Int, type: Int)

Accepts a list of custom providers to attempt to set as the default provider for the specified watch face complication id.

Public methods

getContext

abstract fun getContext(): Context

Returns the watch face's Context.

getHandler

abstract fun getHandler(): Handler

Returns the main thread Handler.

getInitialUserStyle

abstract fun getInitialUserStyle(): UserStyleWireFormat?

Returns the initial user style stored by the system if there is one or null otherwise.

invalidate

@UiThread abstract fun invalidate(): Unit

Schedules a call to Renderer.renderInternal to draw the next frame.

setActiveComplications

abstract fun setActiveComplications(watchFaceComplicationIds: IntArray): Unit

Sets the complications which are active in the watchface. Complication data will be received for these ids.

setComplicationDetails

abstract fun setComplicationDetails(
    complicationId: Int,
    bounds: Rect,
    boundsType: Int,
    types: IntArray
): Unit

Registers details of the complications with the system.

setContentDescriptionLabels

abstract fun setContentDescriptionLabels(labels: Array<ContentDescriptionLabel>): Unit

Sets ContentDescriptionLabels for text-to-speech screen readers to make your complications, buttons, and any other text on your watchface accessible.

setCurrentUserStyle

abstract fun setCurrentUserStyle(userStyle: UserStyleWireFormat): Unit

Registers the watch face's current user style with the system.

setDefaultComplicationProviderWithFallbacks

abstract fun setDefaultComplicationProviderWithFallbacks(
    watchFaceComplicationId: Int,
    providers: List<ComponentName>?,
    fallbackSystemProvider: Int,
    type: Int
): Unit

Accepts a list of custom providers to attempt to set as the default provider for the specified watch face complication id. The custom providers are tried in turn, if the first doesn't exist then the next one is tried and so on. If none of them exist then the specified system provider is set as the default instead.

Parameters
watchFaceComplicationId: Int The watch face's ID for the complication
providers: List<ComponentName>? The list of non-system providers to try in order before falling back to fallbackSystemProvider. This list may be null.
fallbackSystemProvider: Int The system provider to use if none of the providers could be used.
type: Int The type of complication data that should be provided. Must be one of the types defined in ComplicationData