StatefulWatchFaceRuntimeService
public abstract class StatefulWatchFaceRuntimeService<Extra extends Object> extends WatchFaceService
ListenableStatefulWatchFaceRuntimeService |
This class is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
WatchFaceRuntimeService is required to be stateless as multiple can be created in parallel. StatefulWatchFaceRuntimeService 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.
Note because a WatchFaceRuntimeService loads it's resources from another package, it will need the following permission:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
Currently Wear OS only supports the runtime for the Android Watch Face Format (see https://developer.android.com/training/wearables/wff for more details).
Note only one watch face definition per resource only watch face package is supported.
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. |
abstract @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. |
abstract @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. |
abstract @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. |
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 abstract @NonNull ComplicationSlotsManagercreateComplicationSlotsManager(
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull String resourceOnlyWatchFacePackageName,
@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 String resourceOnlyWatchFacePackageName |
The android package from which the watch face definition should be loaded. |
@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 abstract @NonNull UserStyleFlavorscreateUserStyleFlavors(
@NonNull CurrentUserStyleRepository currentUserStyleRepository,
@NonNull ComplicationSlotsManager complicationSlotsManager,
@NonNull String resourceOnlyWatchFacePackageName,
@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 String resourceOnlyWatchFacePackageName |
The android package from which the watch face definition should be loaded. |
@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 abstract @NonNull UserStyleSchemacreateUserStyleSchema(
@NonNull String resourceOnlyWatchFacePackageName,
@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 String resourceOnlyWatchFacePackageName |
The android package from which the watch face definition should be loaded. |
@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 String resourceOnlyWatchFacePackageName,
@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 String resourceOnlyWatchFacePackageName |
The android package from which the watch face definition should be loaded. |
@NonNull Extra extra |
The object returned by |
| Returns | |
|---|---|
@NonNull WatchFace |
A |