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

HeadlessWatchFaceClient

interface HeadlessWatchFaceClient : AutoCloseable
androidx.wear.watchface.client.HeadlessWatchFaceClient

Controls a stateless remote headless watch face. This is mostly intended for use by watch face editor UIs which need to generate screenshots for various styling configurations without affecting the current watchface.

Note clients should call close when finished.

Summary

Public methods
abstract IBinder

Returns the associated IBinder.

abstract Bitmap?
takeComplicationScreenshot(complicationId: Int, renderParameters: RenderParameters, @IntRange(0, 100) compressionQuality: Int, calendarTimeMillis: Long, complicationData: ComplicationData, userStyle: UserStyle?)

Requests for a WebP compressed shared memory backed Bitmap containing a screenshot of the complication with the given settings.

abstract Bitmap
takeWatchFaceScreenshot(renderParameters: RenderParameters, @IntRange(0, 100) compressionQuality: Int, calendarTimeMillis: Long, userStyle: UserStyle?, idToComplicationData: Map<Int, ComplicationData>?)

Requests for a WebP compressed shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

Companion functions
HeadlessWatchFaceClient

Constructs a HeadlessWatchFaceClient from an IBinder.

Properties
abstract Map<Int, ComplicationState>

Map of complication ids to ComplicationState for each complication slot.

abstract Long

The UTC reference preview time for this watch face in milliseconds since the epoch.

abstract UserStyleSchema

The watch face's UserStyleSchema.

Public methods

asBinder

abstract fun asBinder(): IBinder

Returns the associated IBinder. Allows this interface to be passed over AIDL.

takeComplicationScreenshot

@RequiresApi(27) abstract fun takeComplicationScreenshot(
    complicationId: Int,
    renderParameters: RenderParameters,
    @IntRange(0, 100) compressionQuality: Int,
    calendarTimeMillis: Long,
    complicationData: ComplicationData,
    userStyle: UserStyle?
): Bitmap?

Requests for a WebP compressed shared memory backed Bitmap containing a screenshot of the complication with the given settings.

Parameters
complicationId: Int The id of the complication to render
renderParameters: RenderParameters The RenderParameters to draw with
compressionQuality: Int The WebP compression quality, 100 = loss less
calendarTimeMillis: Long The UTC time in milliseconds since the epoch to render with
complicationData: ComplicationData the ComplicationData to render with
userStyle: UserStyle? Optional UserStyle to render with, if null the default style is used
Return
A WebP compressed shared memory backed Bitmap containing a screenshot of the watch face with the given settings, or null if complicationId is unrecognized.

takeWatchFaceScreenshot

@RequiresApi(27) abstract fun takeWatchFaceScreenshot(