WatchFaceService


public abstract class WatchFaceService extends WallpaperService

Known direct subclasses
ListenableWatchFaceService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

StatefulWatchFaceRuntimeService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

StatefulWatchFaceService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

WatchFaceRuntimeService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Known indirect subclasses
ListenableStatefulWatchFaceRuntimeService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

ListenableStatefulWatchFaceService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

ListenableWatchFaceRuntimeService

This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.


WatchFaceService and WatchFace are a pair of classes intended to handle much of the boilerplate needed to implement a watch face without being too opinionated. The suggested structure of a WatchFaceService based watch face is:

import androidx.wear.watchface.CanvasComplicationFactory
import androidx.wear.watchface.CanvasType
import androidx.wear.watchface.ComplicationSlot
import androidx.wear.watchface.ComplicationSlotsManager
import androidx.wear.watchface.Renderer
import androidx.wear.watchface.WatchFace
import androidx.wear.watchface.WatchFaceService
import androidx.wear.watchface.WatchFaceType
import androidx.wear.watchface.WatchState
import androidx.wear.watchface.complications.ComplicationSlotBounds
import androidx.wear.watchface.complications.DefaultComplicationDataSourcePolicy
import androidx.wear.watchface.complications.SystemDataSources
import androidx.wear.watchface.complications.data.ComplicationExperimental
import androidx.wear.watchface.complications.data.ComplicationType
import androidx.wear.watchface.complications.rendering.CanvasComplicationDrawable
import androidx.wear.watchface.complications.rendering.ComplicationDrawable
import androidx.wear.watchface.style.CurrentUserStyleRepository
import androidx.wear.watchface.style.UserStyleSchema
import androidx.wear.watchface.style.UserStyleSetting
import androidx.wear.watchface.style.UserStyleSetting.ListUserStyleSetting
import androidx.wear.watchface.style.UserStyleSetting.Option
import androidx.wear.watchface.style.WatchFaceLayer

class ExampleCanvasWatchFaceService : WatchFaceService() {
    override fun createUserStyleSchema() =
        UserStyleSchema(
            listOf(
                ListUserStyleSetting.Builder(
                        UserStyleSetting.Id(COLOR_STYLE_SETTING),
                        options =
                            listOf(
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(RED_STYLE),
                                        resources,
                                        R.string.colors_style_red,
                                        R.string.colors_style_red_screen_reader
                                    )
                                    .build(),
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(GREEN_STYLE),
                                        resources,
                                        R.string.colors_style_green,
                                        R.string.colors_style_green_screen_reader
                                    )
                                    .build(),
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(BLUE_STYLE),
                                        resources,
                                        R.string.colors_style_blue,
                                        R.string.colors_style_blue_screen_reader
                                    )
                                    .build()
                            ),
                        listOf(
                            WatchFaceLayer.BASE,
                            WatchFaceLayer.COMPLICATIONS,
                            WatchFaceLayer.COMPLICATIONS_OVERLAY
                        ),
                        resources,
                        R.string.colors_style_setting,
                        R.string.colors_style_setting_description
                    )
                    .build(),
                ListUserStyleSetting.Builder(
                        UserStyleSetting.Id(HAND_STYLE_SETTING),
                        options =
                            listOf(
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(CLASSIC_STYLE),
                                        resources,
                                        R.string.hand_style_classic,
                                        R.string.hand_style_classic_screen_reader
                                    )
                                    .build(),
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(MODERN_STYLE),
                                        resources,
                                        R.string.hand_style_modern,
                                        R.string.hand_style_modern_screen_reader
                                    )
                                    .build(),
                                ListUserStyleSetting.ListOption.Builder(
                                        Option.Id(GOTHIC_STYLE),
                                        resources,
                                        R.string.hand_style_gothic,
                                        R.string.hand_style_gothic_screen_reader
                                    )
                                    .build()
                            ),
                        listOf(WatchFaceLayer.COMPLICATIONS_OVERLAY),
                        resources,
                        R.string.hand_style_setting,
                        R.string.hand_style_setting_description
                    )
                    .build()
            )
        )

    @ComplicationExperimental
    override fun createComplicationSlotsManager(
        currentUserStyleRepository: CurrentUserStyleRepository
    ): ComplicationSlotsManager {
        val canvasComplicationFactory = CanvasComplicationFactory { watchState, listener ->
            CanvasComplicationDrawable(ComplicationDrawable(this), watchState, listener)
        }
        return ComplicationSlotsManager(
            listOf(
                ComplicationSlot.createRoundRectComplicationSlotBuilder(
                        /*id */ 0,
                        canvasComplicationFactory,
                        listOf(
                            ComplicationType.RANGED_VALUE,
                            ComplicationType.LONG_TEXT,
                            ComplicationType.SHORT_TEXT,
                            ComplicationType.MONOCHROMATIC_IMAGE,
                            ComplicationType.SMALL_IMAGE
                        ),
                        DefaultComplicationDataSourcePolicy(
                            SystemDataSources.DATA_SOURCE_DAY_OF_WEEK,
                            ComplicationType.SHORT_TEXT
                        ),
                        ComplicationSlotBounds(RectF(0.15625f, 0.1875f, 0.84375f, 0.3125f))
                    )
                    .build(),
                ComplicationSlot.createRoundRectComplicationSlotBuilder(
                        /*id */ 1,
                        canvasComplicationFactory,
                        listOf(
                            ComplicationType.RANGED_VALUE,
                            ComplicationType.LONG_TEXT,
                            ComplicationType.SHORT_TEXT,
                            ComplicationType.MONOCHROMATIC_IMAGE,
                            ComplicationType.SMALL_IMAGE
                        ),
                        DefaultComplicationDataSourcePolicy(
                            SystemDataSources.DATA_SOURCE_STEP_COUNT,
                            ComplicationType.SHORT_TEXT
                        ),
                        ComplicationSlotBounds(RectF(0.1f, 0.5625f, 0.35f, 0.8125f))
                    )
                    .build()
            ),
            currentUserStyleRepository
        )
    }

    inner class MySharedAssets : Renderer.SharedAssets {
        override fun onDestroy() {}
    }

    override suspend fun createWatchFace(
        surfaceHolder: SurfaceHolder,
        watchState: WatchState,
        complicationSlotsManager: ComplicationSlotsManager,
        currentUserStyleRepository: CurrentUserStyleRepository
    ) =
        WatchFace(
            WatchFaceType.ANALOG,
            object :
                Renderer.CanvasRenderer2<MySharedAssets>(
                    surfaceHolder,
                    currentUserStyleRepository,
                    watchState,
                    CanvasType.HARDWARE,
                    interactiveDrawModeUpdateDelayMillis = 16,
                    clearWithBackgroundTintBeforeRenderingHighlightLayer = true
                ) {
                init {
                    // Listen for user style changes.
                    CoroutineScope(Dispatchers.Main.immediate).launch {
                        currentUserStyleRepository.userStyle.collect {
                            // `userStyle` will contain two userStyle categories with options
                            // from the lists above. ..
                        }
                    }
                }

                override fun render(
                    canvas: Canvas,
                    bounds: Rect,
                    zonedDateTime: ZonedDateTime,
                    sharedAssets: MySharedAssets
                ) {
                    // ...
                }

                override fun renderHighlightLayer(
                    canvas: Canvas,
                    bounds: Rect,
                    zonedDateTime: ZonedDateTime,
                    sharedAssets: MySharedAssets
                ) {
                    canvas.drawColor(renderParameters.highlightLayer!!.backgroundTint)

                    // ...
                }

                override suspend fun createSharedAssets(): MySharedAssets {
                    // Insert resource loading here.
                    return MySharedAssets()
                }
            }
        )
}

return ExampleCanvasWatchFaceService()

Sub classes of WatchFaceService are expected to implement createWatchFace which is the factory for making WatchFaces. If the watch faces uses complications then createComplicationSlotsManager should be overridden. All ComplicationSlots are assumed to be enumerated up upfront and passed as a collection into ComplicationSlotsManager's constructor which is returned by createComplicationSlotsManager.

WatchFaceServices are required to be stateless as multiple can be created in parallel. If per instance state is required please use StatefulWatchFaceService.

Watch face styling (color and visual look of watch face elements such as numeric fonts, watch hands and ticks, etc...) and companion editing is directly supported via UserStyleSchema and UserStyleSetting. To enable support for styling override createUserStyleSchema.

WatchFaceService can expose pre-populated style presets by overriding createUserStyleFlavors or via XML (see below). Each presents represents separate style configured with UserStyle and complication slot policies configured with androidx.wear.watchface.complications.DefaultComplicationDataSourcePolicy. The system will only access flavors if metadata tag is present in manifest:

    <meta-data
android:name="androidx.wear.watchface.FLAVORS_SUPPORTED"
android:value="true" />

WatchFaces are initially constructed on a background thread before being used exclusively on the ui thread afterwards. There is a memory barrier between construction and rendering so no special threading primitives are required.

To aid debugging watch face animations, WatchFaceService allows you to speed up or slow down time, and to loop between two instants. This is controlled by MOCK_TIME_INTENT intents with a float extra called "androidx.wear.watchface.extra.MOCK_TIME_SPEED_MULTIPLIE" and to long extras called "androidx.wear.watchface.extra.MOCK_TIME_WRAPPING_MIN_TIME" and "androidx.wear.watchface.extra.MOCK_TIME_WRAPPING_MAX_TIME" (which are UTC time in milliseconds). If minTime is omitted or set to -1 then the current time is sampled as minTime.

E.g., to make time go twice as fast: adb shell am broadcast -a androidx.wear.watchface.MockTime
--ef androidx.wear.watchface.extra.MOCK_TIME_SPEED_MULTIPLIER 2.0

To use the sample on watch face editor UI, import the wear:wear-watchface-editor-samples library and add the following into your watch face's AndroidManifest.xml:

<activity
android:name="androidx.wear.watchface.editor.sample.WatchFaceConfigActivity"
android:exported="true"
android:label="Config"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR" />
<category android:name=
"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

To register a WatchFaceService with the system add a tag to the in your watch face's AndroidManifest.xml:

<service
android:name=".MyWatchFaceServiceClass"
android:exported="true"
android:label="@string/watch_face_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/my_watch_preview" />
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="@drawable/my_watch_circular_preview" />
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="androidx.wear.watchface.editor.action.WATCH_FACE_EDITOR"/>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name=
"com.google.android.wearable.watchface.companionBuiltinConfigurationEnabled"
android:value="true" />
</
service>

Multiple watch faces can be defined in the same package, requiring multiple tags.

By default the system will only allow the user to create a single instance of the watch face. You can choose to allow the user to create multiple instances (each with their own styling and a distinct WatchState.watchFaceInstanceId) by adding this meta-data to your watch face's manifest:

    <meta-data
android:name="androidx.wear.watchface.MULTIPLE_INSTANCES_ALLOWED"
android:value="true" />

A watch face can declare the UserStyleSchema, ComplicationSlots and UserStyleFlavors in XML. The main advantage is simplicity for the developer, however meta data queries (see androidx.wear.watchface.client.WatchFaceMetadataClient) are faster because they can be performed without having to bind to the WatchFaceService.

To use xml inflation, add an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta date tag to your service:

    <meta-data
android:name="androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition"
android:resource="@xml/my_watchface_definition" />

And the linked xml/my_watchface_definition resource must contain a XmlWatchFace node. E.g.:

     <XmlWatchFace xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<UserStyleSchema>
<ListUserStyleSetting
android:icon="@drawable/time_style_icon"
app:affectedWatchFaceLayers="BASE|COMPLICATIONS|COMPLICATIONS_OVERLAY"
app:defaultOptionIndex="1"
app:description="@string/time_style_description"
app:displayName="@string/time_style_name"
app:id="TimeStyle">
<ListOption
android:icon="@drawable/time_style_minimal_icon"
app:displayName="@string/time_style_minimal_name"
app:id="minimal" />
<ListOption
android:icon="@drawable/time_style_seconds_icon"
app:displayName="@string/time_style_seconds_name"
app:id="seconds" />
</ListUserStyleSetting>
</UserStyleSchema>
</ComplicationSlot>
app:slotId="1"
app:boundsType="ROUND_RECT"
app:supportedTypes="SHORT_TEXT|RANGED_VALUE|SMALL_IMAGE"
app:defaultDataSourceType="RANGED_VALUE"
app:systemDataSourceFallback="DATA_SOURCE_WATCH_BATTERY">
<ComplicationSlotBounds
app:left="0.3" app:top="0.7" app:right="0.7" app:bottom="0.9"/>
</ComplicationSlot>
<UserStyleFlavors>
<UserStyleFlavor app:id="flavor1">
<StyleOption app:id="TimeStyle" app:value="minimal"/>
<ComplicationPolicy
app:slotId="1"
app:primaryDataSource="com.package/com.app"
app:primaryDataSourceDefaultType="SHORT_TEXT"
app:systemDataSourceFallback="DATA_SOURCE_DAY_AND_DATE"
app:systemDataSourceFallbackDefaultType="SHORT_TEXT"/>
</UserStyleFlavor>
</UserStyleFlavors>
</XmlWatchFace>

If you use resources references to specify identifiers, they should be locale independent (i.e. translatable="false").

If you use XmlSchemaAndComplicationSlotsDefinition then you shouldn't override createUserStyleSchema or createComplicationSlotsManager. However if tags are defined then you must override getComplicationSlotInflationFactory in order to provide the CanvasComplicationFactory and where necessary edge complication ComplicationTapFilters.

Note the tag does not support configExtras because in general a Bundle can not be inflated from XML.

Note it is an error to define a XmlSchemaAndComplicationSlotsDefinition and not use it.

As of Wear OS 4, complications can provide data using dynamic values, that the platform evaluates continuously and sends the evaluated results to the watch face. Privileged watch faces that can utilize the unevaluated dynamic values, can include the privileged permission com.google.wear.permission.GET_COMPLICATION_DYNAMIC_VALUE in their manifest, which will tell the system to avoid pruning them from the ComplicationData, where they will show up in the relevant fields next to the evaluated values.

use Watch Face Format instead

Summary

Constants

static final int

This field is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public constructors

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public methods

final @NonNull Handler

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull Handler

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull WallpaperService.Engine

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Protected methods

@NonNull ComplicationSlotsManager

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull UserStyleFlavors
@WorkerThread
createUserStyleFlavors(
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull ComplicationSlotsManager complicationSlotsManager
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull UserStyleSchema

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

abstract @NonNull WatchFace
@WorkerThread
createWatchFace(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull WatchState watchState,
    @NonNull ComplicationSlotsManager complicationSlotsManager,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
@UiThread
dump(
    @NonNull FileDescriptor fd,
    @NonNull PrintWriter writer,
    @NonNull String[] args
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

ComplicationSlotInflationFactory

This method is deprecated. Use the version with currentUserStyleRepository argument instead

@NonNull ComplicationSlotInflationFactory

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Inherited methods

From android.content.Context
boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final int
getColor(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull ColorStateList

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @Nullable Drawable
getDrawable(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull String
getString(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull String
getString(int p0, @NonNull Object p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull T
<T extends Object> getSystemService(@NonNull Class<@NonNull T> p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull CharSequence
getText(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull TypedArray

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull TypedArray

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull TypedArray
obtainStyledAttributes(int p0, @NonNull int[] p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull TypedArray
obtainStyledAttributes(
    @Nullable AttributeSet p0,
    @NonNull int[] p1,
    int p2,
    int p3
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendBroadcastWithMultiplePermissions(
    @NonNull Intent p0,
    @NonNull String[] p1
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

From android.content.ContextWrapper
boolean
bindIsolatedService(
    @NonNull Intent p0,
    int p1,
    @NonNull String p2,
    @NonNull Executor p3,
    @NonNull ServiceConnection p4
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean
bindService(
    @NonNull Intent p0,
    int p1,
    @NonNull Executor p2,
    @NonNull ServiceConnection p3
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean
bindServiceAsUser(
    @NonNull Intent p0,
    @NonNull ServiceConnection p1,
    int p2,
    @NonNull UserHandle p3
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull int[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull int[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int
checkContentUriPermissionFull(@NonNull Uri p0, int p1, int p2, int p3)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int
checkPermission(@NonNull String p0, int p1, int p2)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int
checkUriPermission(@NonNull Uri p0, int p1, int p2, int p3)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int
checkUriPermission(
    @Nullable Uri p0,
    @Nullable String p1,
    @Nullable String p2,
    int p3,
    int p4,
    int p5
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull int[]
checkUriPermissions(@NonNull List<@NonNull Uri> p0, int p1, int p2, int p3)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. Deprecated in Java

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
enforceCallingOrSelfUriPermission(
    @NonNull Uri p0,
    int p1,
    @NonNull String p2
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
enforcePermission(@NonNull String p0, int p1, int p2, @Nullable String p3)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
enforceUriPermission(
    @NonNull Uri p0,
    int p1,
    int p2,
    int p3,
    @NonNull String p4
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
enforceUriPermission(
    @Nullable Uri p0,
    @Nullable String p1,
    @Nullable String p2,
    int p3,
    int p4,
    int p5,
    @Nullable String p6
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull ApplicationInfo

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull AssetManager

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull AttributionSource

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Context

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull ClassLoader

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull ContentResolver

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File
getDir(@NonNull String p0, int p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable Display

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Executor

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Looper

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull File[]

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull PackageManager

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable ContextParams

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Resources

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull SharedPreferences

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Object

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

String

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Resources.Theme

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Drawable

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull FileInputStream

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull FileOutputStream
openFileOutput(@NonNull String p0, int p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull SQLiteDatabase
openOrCreateDatabase(
    @NonNull String p0,
    int p1,
    @NonNull SQLiteDatabase.CursorFactory p2
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull SQLiteDatabase

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@NonNull Drawable

This method is deprecated. Deprecated in Java

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Intent

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Intent
registerReceiver(
    @Nullable BroadcastReceiver p0,
    @NonNull IntentFilter p1,
    int p2
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Intent
registerReceiver(
    @Nullable BroadcastReceiver p0,
    @NonNull IntentFilter p1,
    @Nullable String p2,
    @Nullable Handler p3
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Intent
registerReceiver(
    @Nullable BroadcastReceiver p0,
    @NonNull IntentFilter p1,
    @Nullable String p2,
    @Nullable Handler p3,
    int p4
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcast(
    @NonNull Intent p0,
    @Nullable String p1,
    @Nullable Bundle p2
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcast(
    @NonNull Intent p0,
    @Nullable String p1,
    @Nullable BroadcastReceiver p2,
    @Nullable Handler p3,
    int p4,
    @Nullable String p5,
    @Nullable Bundle p6
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcast(
    @NonNull Intent p0,
    @Nullable String p1,
    @Nullable Bundle p2,
    @Nullable BroadcastReceiver p3,
    @Nullable Handler p4,
    int p5,
    @Nullable String p6,
    @Nullable Bundle p7
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcast(
    @NonNull Intent p0,
    @Nullable String p1,
    @Nullable String p2,
    @Nullable BroadcastReceiver p3,
    @Nullable Handler p4,
    int p5,
    @Nullable String p6,
    @Nullable Bundle p7
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcast(
    @NonNull Intent p0,
    int p1,
    @Nullable String p2,
    @Nullable String p3,
    @Nullable BroadcastReceiver p4,
    @Nullable Handler p5,
    @Nullable String p6,
    @Nullable Bundle p7,
    @Nullable Bundle p8
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
sendOrderedBroadcastAsUser(
    @NonNull Intent p0,
    @NonNull UserHandle p1,
    @Nullable String p2,
    @Nullable BroadcastReceiver p3,
    @Nullable Handler p4,
    int p5,
    @Nullable String p6,
    @Nullable Bundle p7
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
sendStickyOrderedBroadcast(
    @NonNull Intent p0,
    @Nullable BroadcastReceiver p1,
    @Nullable Handler p2,
    int p3,
    @Nullable String p4,
    @Nullable Bundle p5
)

This method is deprecated. Deprecated in Java

void
sendStickyOrderedBroadcastAsUser(
    @NonNull Intent p0,
    @NonNull UserHandle p1,
    @Nullable BroadcastReceiver p2,
    @Nullable Handler p3,
    int p4,
    @Nullable String p5,
    @Nullable Bundle p6
)

This method is deprecated. Deprecated in Java

void
setTheme(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
startActivities(@NonNull Intent[] p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
startActivities(@NonNull Intent[] p0, @Nullable Bundle p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable ComponentName

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean
startInstrumentation(
    @NonNull ComponentName p0,
    @Nullable String p1,
    @Nullable Bundle p2
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
startIntentSender(
    @NonNull IntentSender p0,
    @Nullable Intent p1,
    int p2,
    int p3,
    int p4
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
startIntentSender(
    @NonNull IntentSender p0,
    @Nullable Intent p1,
    int p2,
    int p3,
    int p4,
    @Nullable Bundle p5
)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

@Nullable ComponentName

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
updateServiceGroup(@NonNull ServiceConnection p0, int p1, int p2)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

From android.app.Service
void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final @NonNull Application

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final int

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
onStart(@NonNull Intent p0, int p1)

This method is deprecated. Deprecated in Java

int
onStartCommand(@NonNull Intent p0, int p1, int p2)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
onTimeout(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
onTimeout(int p0, int p1)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void
onTrimMemory(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final void
startForeground(int p0, @NonNull Notification p1, int p2)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final void
stopForeground(boolean p0)

This method is deprecated. Deprecated in Java

final void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final void
stopSelf(int p0)

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

final boolean

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

From android.service.wallpaper.WallpaperService
final IBinder

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

void

This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Constants

MAX_CREATE_WATCHFACE_TIME_MILLIS

public static final int MAX_CREATE_WATCHFACE_TIME_MILLIS = 5000

The maximum permitted duration of WatchFaceService.createWatchFace.

Public constructors

WatchFaceService

Added in 1.0.0
Deprecated in 1.3.0-alpha06
public WatchFaceService()

Public methods

getBackgroundThreadHandler

Added in 1.0.0
Deprecated in 1.3.0-alpha06
public final @NonNull Handler getBackgroundThreadHandler()

Returns the lazily constructed background thread Handler. During initialization createUserStyleSchema, createComplicationSlotsManager and createWatchFace are posted on this handler.

getUiThreadHandler

Added in 1.0.0
Deprecated in 1.3.0-alpha06
public final @NonNull Handler getUiThreadHandler()

Returns the ui thread Handler.

onConfigurationChanged

public void onConfigurationChanged(@NonNull Configuration newConfig)

onCreateEngine

Added in 1.0.0
Deprecated in 1.3.0-alpha06
public final @NonNull WallpaperService.Engine onCreateEngine()

Creates an interactive engine for WallpaperService.

Protected methods

createComplicationSlotsManager

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@WorkerThread
protected @NonNull ComplicationSlotsManager createComplicationSlotsManager(
    @NonNull CurrentUserStyleRepository currentUserStyleRepository
)

If the WatchFaceService's manifest doesn't define a androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta data tag then override this factory method to create a non-empty ComplicationSlotsManager. This manager will be passed to createUserStyleFlavors and createWatchFace. This will be called from a background thread but the ComplicationSlotsManager should be accessed exclusively from the UiThread afterwards.

Parameters
@NonNull CurrentUserStyleRepository currentUserStyleRepository

The CurrentUserStyleRepository constructed using the UserStyleSchema returned by createUserStyleSchema.

createUserStyleFlavors

Added in 1.2.0
Deprecated in 1.3.0-alpha06
@WorkerThread
protected @NonNull UserStyleFlavors createUserStyleFlavors(
    @NonNull CurrentUserStyleRepository currentUserStyleRepository,
    @NonNull ComplicationSlotsManager complicationSlotsManager
)

If the WatchFaceService's manifest doesn't define a androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta data tag then override this factory method to create non-empty UserStyleFlavors. This is called on a background thread. The system reads the flavors once and changes may be ignored until the APK is updated. Metadata tag "androidx.wear.watchface.FLAVORS_SUPPORTED" should be added to let the system know the service supports flavors.

Parameters
@NonNull CurrentUserStyleRepository currentUserStyleRepository

The CurrentUserStyleRepository constructed using the UserStyleSchema returned by createUserStyleSchema.

@NonNull ComplicationSlotsManager complicationSlotsManager

The ComplicationSlotsManager returned by createComplicationSlotsManager

Returns
@NonNull UserStyleFlavors

The UserStyleFlavors, which is exposed to the system.

createUserStyleSchema

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@WorkerThread
protected @NonNull UserStyleSchema createUserStyleSchema()

If the WatchFaceService's manifest doesn't define an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition meta data tag then override this factory method to create a non-empty UserStyleSchema. A CurrentUserStyleRepository constructed with this schema will be passed to createComplicationSlotsManager, createUserStyleFlavors and createWatchFace. This is called on a background thread.

createWatchFace

@WorkerThread
protected abstract @NonNull WatchFace createWatchFace(
    @NonNull SurfaceHolder surfaceHolder,
    @NonNull WatchState watchState,
    @NonNull ComplicationSlotsManager complicationSlotsManager,
    @NonNull CurrentUserStyleRepository currentUserStyleRepository
)

Override this factory method to create your WatchFaceImpl. This method will be called by the library on a background thread, if possible any expensive initialization should be done asynchronously. The WatchFace and its Renderer should be accessed exclusively from the UiThread afterwards. There is a memory barrier between construction and rendering so no special threading primitives are required.

Warning the system will likely time out waiting for watch face initialization if it takes longer than MAX_CREATE_WATCHFACE_TIME_MILLIS milliseconds.

Parameters
@NonNull SurfaceHolder surfaceHolder

The SurfaceHolder to pass to the Renderer's constructor.

@NonNull WatchState watchState

The WatchState for the watch face.

@NonNull ComplicationSlotsManager complicationSlotsManager

The ComplicationSlotsManager returned by createComplicationSlotsManager.

@NonNull CurrentUserStyleRepository currentUserStyleRepository

The CurrentUserStyleRepository constructed using the UserStyleSchema returned by createUserStyleSchema.

Returns
@NonNull WatchFace

A WatchFace whose Renderer uses the provided surfaceHolder.

dump

@UiThread
protected void dump(
    @NonNull FileDescriptor fd,
    @NonNull PrintWriter writer,
    @NonNull String[] args
)

getComplicationSlotInflationFactory

Added in 1.1.0
Deprecated in 1.2.0
@WorkerThread
protected ComplicationSlotInflationFactory getComplicationSlotInflationFactory()

Used when inflating ComplicationSlots from XML (i.e the manifest contains androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition metadata) to provide a ComplicationSlotInflationFactory which provides the CanvasComplicationFactory and where necessary edge complication ComplicationTapFilters needed for inflating ComplicationSlots.

If an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition metadata tag is defined for your WatchFaceService 's manifest, and your XML includes tags then you must override this method.

getComplicationSlotInflationFactory

Added in 1.2.0
Deprecated in 1.3.0-alpha06
@WorkerThread
protected @NonNull ComplicationSlotInflationFactory getComplicationSlotInflationFactory(
    @NonNull CurrentUserStyleRepository currentUserStyleRepository
)

Used when inflating ComplicationSlots from XML (i.e the manifest contains androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition metadata) to provide a ComplicationSlotInflationFactory which provides the CanvasComplicationFactory and where necessary edge complication ComplicationTapFilters needed for inflating ComplicationSlots.

If an androidx.wear.watchface.XmlSchemaAndComplicationSlotsDefinition metadata tag is defined for your WatchFaceService 's manifest, and your XML includes tags then you must override this method. A NotImplementedError exception will be thrown if you don't.

Parameters
@NonNull CurrentUserStyleRepository currentUserStyleRepository

The CurrentUserStyleRepository constructed using the UserStyleSchema returned by createUserStyleSchema.