StatefulWatchFaceService
abstract class StatefulWatchFaceService<Extra : Any?> : WatchFaceService
ListenableStatefulWatchFaceService |
This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
WatchFaceService is required to be stateless as multiple can be created in parallel. StatefulWatchFaceService allows for metadata to be associated with watch faces on a per instance basis. This state is created by createExtra and is passed into other methods.
use Watch Face Format instead
Summary
Public constructors |
|---|
<Extra : Any?> This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Protected functions |
|
|---|---|
final ComplicationSlotsManager |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
open ComplicationSlotsManager |
@WorkerThreadThis function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract Extra |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final UserStyleFlavors |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
open UserStyleFlavors |
@WorkerThreadThis function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final UserStyleSchema |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
open UserStyleSchema |
@WorkerThreadThis function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final suspend WatchFace |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract suspend WatchFace |
@WorkerThreadThis function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final ComplicationSlotInflationFactory |
This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
open ComplicationSlotInflationFactory |
@WorkerThreadThis function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Protected functions
createComplicationSlotsManager
protected final funcreateComplicationSlotsManager(
currentUserStyleRepository: CurrentUserStyleRepository
): ComplicationSlotsManager
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 | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
| Returns | |
|---|---|
ComplicationSlotsManager |
The |
createComplicationSlotsManager
@WorkerThread
protected open funcreateComplicationSlotsManager(
currentUserStyleRepository: CurrentUserStyleRepository,
extra: Extra
): ComplicationSlotsManager
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 | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
extra: Extra |
The object returned by |
| Returns | |
|---|---|
ComplicationSlotsManager |
The |
createExtra
protected abstract fun createExtra(): ExtraConstructs the user defined Extra object which is passed as a parameter to the other methods.
createUserStyleFlavors
protected final funcreateUserStyleFlavors(
currentUserStyleRepository: CurrentUserStyleRepository,
complicationSlotsManager: ComplicationSlotsManager
): UserStyleFlavors
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 | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
complicationSlotsManager: ComplicationSlotsManager |
The |
| Returns | |
|---|---|
UserStyleFlavors |
The |
createUserStyleFlavors
@WorkerThread
protected open funcreateUserStyleFlavors(
currentUserStyleRepository: CurrentUserStyleRepository,
complicationSlotsManager: ComplicationSlotsManager,
extra: Extra
): UserStyleFlavors
If the WatchFaceService's manifest doesn't define an 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 | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
complicationSlotsManager: ComplicationSlotsManager |
The |
extra: Extra |
The object returned by |
| Returns | |
|---|---|
UserStyleFlavors |
The |
createUserStyleSchema
protected final funcreateUserStyleSchema(): UserStyleSchema
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.
| Returns | |
|---|---|
UserStyleSchema |
The |
createUserStyleSchema
@WorkerThread
protected open funcreateUserStyleSchema(extra: Extra): UserStyleSchema
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.
| Parameters | |
|---|---|
extra: Extra |
The object returned by |
| Returns | |
|---|---|
UserStyleSchema |
The |
createWatchFace
protected final suspend funcreateWatchFace(
surfaceHolder: SurfaceHolder,
watchState: WatchState,
complicationSlotsManager: ComplicationSlotsManager,
currentUserStyleRepository: CurrentUserStyleRepository
): WatchFace
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 | |
|---|---|
surfaceHolder: SurfaceHolder |
The |
watchState: WatchState |
The |
complicationSlotsManager: ComplicationSlotsManager |
The |
currentUserStyleRepository: CurrentUserStyleRepository |
The |
| Returns | |
|---|---|
WatchFace |
A |
createWatchFace
@WorkerThread
protected abstract suspend funcreateWatchFace(
surfaceHolder: SurfaceHolder,
watchState: WatchState,
complicationSlotsManager: ComplicationSlotsManager,
currentUserStyleRepository: CurrentUserStyleRepository,
extra: Extra
): WatchFace
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 WatchFaceService.MAX_CREATE_WATCHFACE_TIME_MILLIS milliseconds.
| Parameters | |
|---|---|
surfaceHolder: SurfaceHolder |
The |
watchState: WatchState |
The |
complicationSlotsManager: ComplicationSlotsManager |
The |
currentUserStyleRepository: CurrentUserStyleRepository |
The |
extra: Extra |
The object returned by |
| Returns | |
|---|---|
WatchFace |
A |
getComplicationSlotInflationFactory
protected final fungetComplicationSlotInflationFactory(
currentUserStyleRepository: CurrentUserStyleRepository
): ComplicationSlotInflationFactory
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 NotImplementedError exception will be thrown if you don't.
| Parameters | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
getComplicationSlotInflationFactory
@WorkerThread
protected open fungetComplicationSlotInflationFactory(
currentUserStyleRepository: CurrentUserStyleRepository,
extra: Extra
): ComplicationSlotInflationFactory
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 NotImplementedError exception will be thrown if you don't.
| Parameters | |
|---|---|
currentUserStyleRepository: CurrentUserStyleRepository |
The |
extra: Extra |
The object returned by |