WatchFaceMetadataClient


interface WatchFaceMetadataClient : AutoCloseable


Interface for fetching watch face metadata. E.g. the UserStyleSchema and ComplicationSlotMetadata. This must be closed after use to release resources.

Summary

Nested types

Exception thrown by createWatchFaceControlClient if the remote service can't be bound.

Exception thrown by WatchFaceControlClient methods if the service dies during start up.

Public companion functions

suspend WatchFaceMetadataClient
create(context: Context, watchFaceName: ComponentName)

Constructs a WatchFaceMetadataClient for fetching metadata for the specified watch face.

suspend WatchFaceMetadataClient
createForRuntime(
    context: Context,
    watchFaceName: ComponentName,
    runtimePackage: String
)

Constructs a WatchFaceMetadataClient for fetching metadata for the specified resource only watch face from its runtime.

Public properties

Boolean

Whether or not the UserStyleSchema is static and won't change unless the APK is updated.

Inherited functions

From java.lang.AutoCloseable

Public companion functions

create

suspend fun create(context: Context, watchFaceName: ComponentName): WatchFaceMetadataClient

Constructs a WatchFaceMetadataClient for fetching metadata for the specified watch face.

Parameters
context: Context

Calling application's Context.

watchFaceName: ComponentName

The ComponentName of the watch face to fetch meta data from.

Returns
WatchFaceMetadataClient

The WatchFaceMetadataClient if there is one.

Throws
androidx.wear.watchface.client.WatchFaceMetadataClient.ServiceNotBoundException

if the underlying watch face control service can not be bound or a ServiceStartFailureException if the watch face dies during startup. If the service's manifest contains an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta data node then PackageManager.NameNotFoundException is thrown if watchFaceName is invalid.

createForRuntime

suspend fun createForRuntime(
    context: Context,
    watchFaceName: ComponentName,
    runtimePackage: String
): WatchFaceMetadataClient

Constructs a WatchFaceMetadataClient for fetching metadata for the specified resource only watch face from its runtime. A resource only watch face runtime is a special watch face that knows how to load watch faces from resources in another package that contains only resources and no executable code.

Parameters
context: Context

Calling application's Context.

watchFaceName: ComponentName

The ComponentName of the watch face to fetch meta data from.

runtimePackage: String

The package that contains the Resource only Watch Face runtime.

Returns
WatchFaceMetadataClient

The WatchFaceMetadataClient if there is one.

Throws
androidx.wear.watchface.client.WatchFaceMetadataClient.ServiceNotBoundException

if the underlying watch face control service can not be bound or a ServiceStartFailureException if the watch face dies during startup. If the service's manifest contains an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta data node then PackageManager.NameNotFoundException is thrown if watchFaceName is invalid.

Public functions

getComplicationSlotMetadataMap

Added in 1.1.0
fun getComplicationSlotMetadataMap(): Map<IntComplicationSlotMetadata>

Returns a map of androidx.wear.watchface.ComplicationSlot ID to ComplicationSlotMetadata for each slot in the watch face's androidx.wear.watchface.ComplicationSlotsManager.

Throws
kotlin.RuntimeException

if the watch face threw an exception while trying to service the request or there was a communication problem with watch face process.

getUserStyleFlavors

Added in 1.2.0
fun getUserStyleFlavors(): UserStyleFlavors

Returns the watch face's UserStyleFlavors.

Throws
kotlin.RuntimeException

if the watch face threw an exception while trying to service the request or there was a communication problem with watch face process.

getUserStyleSchema

Added in 1.1.0
fun getUserStyleSchema(): UserStyleSchema

Returns the watch face's UserStyleSchema.

Throws
kotlin.RuntimeException

if the watch face threw an exception while trying to service the request or there was a communication problem with watch face process.

Public properties

isUserStyleSchemaStatic

Added in 1.1.0
val isUserStyleSchemaStaticBoolean

Whether or not the UserStyleSchema is static and won't change unless the APK is updated.