StatefulWatchFaceService
public abstract class StatefulWatchFaceService<Extra extends Object> extends 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 extends Object> This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Protected methods |
|
|---|---|
final @NonNull ComplicationSlotsManager |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
@NonNull ComplicationSlotsManager |
@WorkerThreadThis method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract @NonNull Extra |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final @NonNull UserStyleFlavors |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
@NonNull UserStyleFlavors |
@WorkerThreadThis method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final @NonNull UserStyleSchema |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
@NonNull UserStyleSchema |
@WorkerThreadThis method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final @NonNull WatchFace |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
abstract @NonNull WatchFace |
@WorkerThreadThis method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
final @NonNull ComplicationSlotInflationFactory |
This method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
@NonNull ComplicationSlotInflationFactory |
@WorkerThreadThis method is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Protected methods
createComplicationSlotsManager
protected final @NonNull ComplicationSlotsManagercreateComplicationSlotsManager(
@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 |
| Returns | |
|---|---|
@NonNull ComplicationSlotsManager |
The |
createComplicationSlotsManager
@WorkerThread
protected @NonNull ComplicationSlotsManagercreateComplicationSlotsManager(
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull Extra extra
)
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 |
@NonNull Extra extra |
The object returned by |
| Returns | |
|---|---|
@NonNull ComplicationSlotsManager |
The |
createExtra
protected abstract @NonNull ExtracreateExtra()
Constructs the user defined Extra object which is passed as a parameter to the other methods.
createUserStyleFlavors
protected final @NonNull UserStyleFlavorscreateUserStyleFlavors(
@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 |
@NonNull ComplicationSlotsManager complicationSlotsManager |
The |
| Returns | |
|---|---|
@NonNull UserStyleFlavors |
The |
createUserStyleFlavors
@WorkerThread
protected @NonNull UserStyleFlavorscreateUserStyleFlavors(
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull ComplicationSlotsManager complicationSlotsManager,
@NonNull Extra extra
)
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 | |
|---|---|
@NonNull CurrentUserStyleRepository currentUserStyleRepository |
The |
@NonNull ComplicationSlotsManager complicationSlotsManager |
The |
@NonNull Extra extra |
The object returned by |
| Returns | |
|---|---|
@NonNull UserStyleFlavors |
The |
createUserStyleSchema
protected final @NonNull UserStyleSchemacreateUserStyleSchema()
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 | |
|---|---|
@NonNull UserStyleSchema |
The |
createUserStyleSchema
@WorkerThread
protected @NonNull UserStyleSchemacreateUserStyleSchema(@NonNull Extra extra)
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 | |
|---|---|
@NonNull Extra extra |
The object returned by |
| Returns | |
|---|---|
@NonNull UserStyleSchema |
The |
createWatchFace
protected final @NonNull WatchFacecreateWatchFace(
@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 |
@NonNull WatchState watchState |
The |
@NonNull ComplicationSlotsManager complicationSlotsManager |
The |
@NonNull CurrentUserStyleRepository currentUserStyleRepository |
The |
| Returns | |
|---|---|
@NonNull WatchFace |
A |
createWatchFace
@WorkerThread
protected abstract @NonNull WatchFacecreateWatchFace(
@NonNull SurfaceHolder surfaceHolder,
@NonNull WatchState watchState,
@NonNull ComplicationSlotsManager complicationSlotsManager,
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull Extra extra
)
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 | |
|---|---|
@NonNull SurfaceHolder surfaceHolder |
The |
@NonNull WatchState watchState |
The |
@NonNull ComplicationSlotsManager complicationSlotsManager |
The |
@NonNull CurrentUserStyleRepository currentUserStyleRepository |
The |
@NonNull Extra extra |
The object returned by |
| Returns | |
|---|---|
@NonNull WatchFace |
A |
getComplicationSlotInflationFactory
protected final @NonNull ComplicationSlotInflationFactorygetComplicationSlotInflationFactory(
@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 NotImplementedError exception will be thrown if you don't.
| Parameters | |
|---|---|
@NonNull CurrentUserStyleRepository currentUserStyleRepository |
The |
getComplicationSlotInflationFactory
@WorkerThread
protected @NonNull ComplicationSlotInflationFactorygetComplicationSlotInflationFactory(
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull Extra extra
)
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 | |
|---|---|
@NonNull CurrentUserStyleRepository currentUserStyleRepository |
The |
@NonNull Extra extra |
The object returned by |