WatchFaceControlClient
public interface WatchFaceControlClient extends AutoCloseable
ListenableWatchFaceControlClient |
This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Connects to a watch face's WatchFaceControlService which allows the user to control the watch face.
use Watch Face Format instead
Summary
Nested types |
|---|
public final class WatchFaceControlClient.ServiceNotBoundException extends ExceptionThis class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
public final class WatchFaceControlClient.ServiceStartFailureException extends ExceptionThis class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Public methods |
|
|---|---|
abstract HeadlessWatchFaceClient |
This method is deprecated. Creating a headless client without a watchface ID is deprecated |
default HeadlessWatchFaceClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
default static final @NonNull WatchFaceControlClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
default static final @NonNull WatchFaceControlClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract @NonNull Map<@NonNull Integer, @NonNull DefaultComplicationDataSourcePolicyAndType> |
This method is deprecated. Use the WatchFaceMetadataClient instead. |
abstract @NonNull EditorServiceClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract InteractiveWatchFaceClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract @NonNull InteractiveWatchFaceClient |
This method is deprecated. Use an overload that specifies Consumer<String> |
default @NonNull InteractiveWatchFaceClient |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
default boolean |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Inherited methods |
||
|---|---|---|
|
Public methods
abstract HeadlessWatchFaceClientcreateHeadlessWatchFaceClient(
@NonNull ComponentName watchFaceName,
@NonNull DeviceConfig deviceConfig,
@Px int surfaceWidth,
@Px int surfaceHeight
)
Creates a HeadlessWatchFaceClient with the specified DeviceConfig. Screenshots made with HeadlessWatchFaceClient.renderWatchFaceToBitmap will be surfaceWidth x surfaceHeight in size.
When finished call HeadlessWatchFaceClient.close to release resources.
| Parameters | |
|---|---|
@NonNull ComponentName watchFaceName |
The |
@NonNull DeviceConfig deviceConfig |
The hardware |
@Px int surfaceWidth |
The width of screen shots taken by the |
@Px int surfaceHeight |
The height of screen shots taken by the |
| Returns | |
|---|---|
HeadlessWatchFaceClient |
The |
createHeadlessWatchFaceClient
default HeadlessWatchFaceClientcreateHeadlessWatchFaceClient(
@NonNull String id,
@NonNull ComponentName watchFaceName,
@NonNull DeviceConfig deviceConfig,
@Px int surfaceWidth,
@Px int surfaceHeight
)
Creates a HeadlessWatchFaceClient with the specified DeviceConfig. Screenshots made with HeadlessWatchFaceClient.renderWatchFaceToBitmap will be surfaceWidth x surfaceHeight in size.
When finished call HeadlessWatchFaceClient.close to release resources.
| Parameters | |
|---|---|
@NonNull String id |
The ID for the requested |
@NonNull ComponentName watchFaceName |
The |
@NonNull DeviceConfig deviceConfig |
The hardware |
@Px int surfaceWidth |
The width of screen shots taken by the |
@Px int surfaceHeight |
The height of screen shots taken by the |
| Returns | |
|---|---|
HeadlessWatchFaceClient |
The |
createWatchFaceControlClient
default static final @NonNull WatchFaceControlClientcreateWatchFaceControlClient(
@NonNull Context context,
@NonNull String watchFacePackageName
)
Constructs a WatchFaceControlClient which attempts to connect to a watch face in the android package watchFacePackageName.
| Parameters | |
|---|---|
@NonNull Context context |
Calling application's |
@NonNull String watchFacePackageName |
The name of the package containing the watch face control service to bind to. |
| Returns | |
|---|---|
@NonNull WatchFaceControlClient |
The |
| Throws | |
|---|---|
androidx.wear.watchface.client.WatchFaceControlClient.ServiceNotBoundException |
if the watch face control service can not be bound or a |
createWatchFaceRuntimeControlClient
default static final @NonNull WatchFaceControlClientcreateWatchFaceRuntimeControlClient(
@NonNull Context context,
@NonNull String runtimePackageName,
@NonNull String resourceOnlyWatchFacePackageName
)
Similar createWatchFaceControlClient this constructs a WatchFaceControlClient which attempts to connect to the watch face runtime in the android package runtimePackageName.
A watch face runtime is a special type of watch face, which renders a watch face described by resources in another package resourceOnlyWatchFacePackageName.
Currently Wear OS only supports the runtime for the Android Watch Face Format (see https://developer.android.com/training/wearables/wff for more details).
| Parameters | |
|---|---|
@NonNull Context context |
Calling application's |
@NonNull String runtimePackageName |
The name of the package containing the watch face runtime's control service to bind to. |
@NonNull String resourceOnlyWatchFacePackageName |
The name of the package from which to load the resource only watch face. This is exposed to the runtime via WatchFaceService.resourceOnlyWatchFacePackageName. Note only one watch face definition per resource only watch face package is supported. |
| Returns | |
|---|---|
@NonNull WatchFaceControlClient |
The |
| Throws | |
|---|---|
androidx.wear.watchface.client.WatchFaceControlClient.ServiceNotBoundException |
if the watch face control service can not be bound or a |
abstract @NonNull Map<@NonNull Integer, @NonNull DefaultComplicationDataSourcePolicyAndType>getDefaultComplicationDataSourcePoliciesAndType(
@NonNull ComponentName watchFaceName
)
Returns a map of androidx.wear.watchface.ComplicationSlot id to the DefaultComplicationDataSourcePolicyAndType for each androidx.wear.watchface.ComplicationSlot in the watchface corresponding to watchFaceName. Where possible a fast path is used that doesn't need to fully construct the corresponding watch face.
| Parameters | |
|---|---|
@NonNull ComponentName watchFaceName |
The |
getEditorServiceClient
abstract @NonNull EditorServiceClientgetEditorServiceClient()
getInteractiveWatchFaceClientInstance
abstract InteractiveWatchFaceClientgetInteractiveWatchFaceClientInstance(@NonNull String instanceId)
Returns the InteractiveWatchFaceClient for the given instance id, or null if no such instance exists.
When finished call InteractiveWatchFaceClient.close to release resources.
| Returns | |
|---|---|
InteractiveWatchFaceClient |
The |
getOrCreateInteractiveWatchFaceClient
abstract @NonNull InteractiveWatchFaceClientgetOrCreateInteractiveWatchFaceClient(
@NonNull String id,
@NonNull DeviceConfig deviceConfig,
@NonNull WatchUiState watchUiState,
UserStyleData userStyle,
Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData
)
Requests either an existing InteractiveWatchFaceClient with the specified id or schedules creation of an InteractiveWatchFaceClient for the next time the WallpaperService creates an engine.
NOTE that currently only one InteractiveWatchFaceClient per process can exist at a time.
| Parameters | |
|---|---|
@NonNull String id |
The ID for the requested |
@NonNull DeviceConfig deviceConfig |
The |
@NonNull WatchUiState watchUiState |
The initial |
UserStyleData userStyle |
Optional |
Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData |
The initial |
| Returns | |
|---|---|
@NonNull InteractiveWatchFaceClient |
The |
| Throws | |
|---|---|
androidx.wear.watchface.client.WatchFaceControlClient.ServiceStartFailureException |
if the watchface dies during startup. |
getOrCreateInteractiveWatchFaceClient
default @NonNull InteractiveWatchFaceClientgetOrCreateInteractiveWatchFaceClient(
@NonNull String instanceId,
@NonNull DeviceConfig deviceConfig,
@NonNull WatchUiState watchUiState,
UserStyleData userStyle,
Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData,
@NonNull Executor previewImageUpdateRequestedExecutor,
@NonNull Consumer<@NonNull String> previewImageUpdateRequestedListener
)
Requests either an existing InteractiveWatchFaceClient with the specified instanceId or schedules creation of an InteractiveWatchFaceClient for the next time the WallpaperService creates an engine.
NOTE that currently only one InteractiveWatchFaceClient per process can exist at a time.
| Parameters | |
|---|---|
@NonNull String instanceId |
The ID for the requested |
@NonNull DeviceConfig deviceConfig |
The |
@NonNull WatchUiState watchUiState |
The initial |
UserStyleData userStyle |
Optional |
Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData |
The initial |
@NonNull Executor previewImageUpdateRequestedExecutor |
The |
@NonNull Consumer<@NonNull String> previewImageUpdateRequestedListener |
The |
| Returns | |
|---|---|
@NonNull InteractiveWatchFaceClient |
The |
| Throws | |
|---|---|
androidx.wear.watchface.client.WatchFaceControlClient.ServiceStartFailureException |
if the watchface dies during startup. |
hasComplicationDataCache
default boolean hasComplicationDataCache()Whether or not the watch face has a ComplicationData cache. Based on this the system may wish to adopt a different strategy for sending complication data. E.g. sending initial blank complications before fetching the real ones is not necessary.