Android 12 Developer Preview is here! Try it out, and give us your feedback!

ComplicationsManager

class ComplicationsManager
kotlin.Any
   ↳ androidx.wear.watchface.ComplicationsManager

The Complications associated with the WatchFace. Dynamic creation of complications isn't supported, however complications can be enabled and disabled by ComplicationsUserStyleSetting.

Summary

Nested classes
abstract

Interface used to report user taps on the complication.

Public constructors
<init>(complicationCollection: Collection<Complication>, userStyleRepository: UserStyleRepository)

The Complications associated with the WatchFace.

Public methods
Unit

Adds a TapCallback which is called whenever the user interacts with a complication.

Unit

Brings attention to the complication by briefly highlighting it to provide visual feedback when the user has tapped on it.

operator Complication?
get(id: Int)

Returns the Complication corresponding to id, if there is one, or null.

Complication?

Returns the background complication if there is one or null otherwise.

Complication?

Returns the id of the complication at coordinates x, y or null if there isn't one.

Unit

Removes a TapCallback previously added by addTapListener.

Properties
Map<Int, Complication>

A map of complication IDs to complications.

Public constructors

<init>

ComplicationsManager(
    complicationCollection: Collection<Complication>,
    userStyleRepository: UserStyleRepository)

The Complications associated with the WatchFace. Dynamic creation of complications isn't supported, however complications can be enabled and disabled by ComplicationsUserStyleSetting.

Public methods

addTapListener

@UiThread fun addTapListener(tapCallback: ComplicationsManager.TapCallback): Unit

Adds a TapCallback which is called whenever the user interacts with a complication.

bringAttentionToComplication

@UiThread fun bringAttentionToComplication(complicationId: Int): Unit

Brings attention to the complication by briefly highlighting it to provide visual feedback when the user has tapped on it.

Parameters
complicationId: Int The watch face's ID of the complication to briefly highlight

get

operator fun get(id: Int): Complication?

Returns the Complication corresponding to id, if there is one, or null.

getBackgroundComplication

fun getBackgroundComplication(): Complication?

Returns the background complication if there is one or null otherwise.

Return
The background complication if there is one or null otherwise

getComplicationAt

fun getComplicationAt(
    x: Int,
    y: Int
): Complication?

Returns the id of the complication at coordinates x, y or null if there isn't one.

Parameters
x: Int The x coordinate of the point to perform a hit test
y: Int The y coordinate of the point to perform a hit test
Return
The complication at coordinates x, y or {@code null} if there isn't one

removeTapListener

@UiThread fun removeTapListener(tapCallback: ComplicationsManager.TapCallback): Unit

Removes a TapCallback previously added by addTapListener.

Properties

complications

val complications: Map<Int, Complication>

A map of complication IDs to complications.