ComplicationDataSourceInfoRetriever


class ComplicationDataSourceInfoRetriever : AutoCloseable


Retrieves Result for a watch face's complications.

To use construct an instance and call retrieveComplicationDataSourceInfo which returns an array of Result objects.

Further calls to retrieveComplicationDataSourceInfo may be made using the same instance of this class, but close must be called when it is no longer needed. Once release has been called, further retrieval attempts will fail.

Summary

Public constructors

Public functions

open Unit

Releases the connection to the complication system used by this class.

suspend Array<ComplicationDataSourceInfoRetriever.Result>?
retrieveComplicationDataSourceInfo(
    watchFaceComponent: ComponentName,
    watchFaceComplicationIds: IntArray
)

Requests Result for the specified complication ids on the specified watch face.

suspend ComplicationData?
@RequiresApi(value = 30)
retrievePreviewComplicationData(
    complicationDataSourceComponent: ComponentName,
    complicationType: ComplicationType
)

Requests preview ComplicationData for a complication data source ComponentName and ComplicationType.

Public constructors

ComplicationDataSourceInfoRetriever

Added in 1.0.0
ComplicationDataSourceInfoRetriever(context: Context)
Parameters
context: Context

the current context

Public functions

close

Added in 1.0.0
open fun close(): Unit

Releases the connection to the complication system used by this class. This must be called when the retriever is no longer needed.

Any outstanding or subsequent futures returned by retrieveComplicationDataSourceInfo will resolve with null.

This class implements the Java AutoClosable interface and may be used with try-with-resources.

retrieveComplicationDataSourceInfo

suspend fun retrieveComplicationDataSourceInfo(
    watchFaceComponent: ComponentName,
    watchFaceComplicationIds: IntArray
): Array<ComplicationDataSourceInfoRetriever.Result>?

Requests Result for the specified complication ids on the specified watch face. When the info is received, the listener will receive a callback for each id. These callbacks will occur on the main thread.

This will only work if the package of the current app is the same as the package of the specified watch face.

Parameters
watchFaceComponent: ComponentName

the ComponentName of the WatchFaceService for which info is being requested

watchFaceComplicationIds: IntArray

ids of the complications that info is being requested for

Returns
Array<ComplicationDataSourceInfoRetriever.Result>?

An array of Result. If the look up fails null will be returned.

retrievePreviewComplicationData

@RequiresApi(value = 30)
suspend fun retrievePreviewComplicationData(
    complicationDataSourceComponent: ComponentName,
    complicationType: ComplicationType
): ComplicationData?

Requests preview ComplicationData for a complication data source ComponentName and ComplicationType. Note if null is returned ComplicationDataSourceInfo.fallbackPreviewData can be used to generate fallback preview data based on the name and icon of the provider.

Parameters
complicationDataSourceComponent: ComponentName

The ComponentName of the complication data source from which preview data is requested.

complicationType: ComplicationType

The requested ComplicationType for the preview data.

Returns
ComplicationData?

The preview ComplicationData or null if the complication data source component doesn't exist, or if it doesn't support complicationType, or if the remote service doesn't support this API.