WatchFacePushManager
public interface WatchFacePushManager
The Watch Face Push API allows a Wear OS app to install a watch face on a watch programmatically. The watch faces will then be available in the watch carousel similarly to watch faces that are downloaded from Play Store. It's important to note that all functions in this API operate only on watch faces that have been added by the calling application. Watch faces added by other apps or pre-existing on the device cannot be managed using this API.
Example usage:
lateinit var wf1: android.os.ParcelFileDescriptor
val token1 = "1234" // Get it from the provided validation library.
lateinit var wf2: android.os.ParcelFileDescriptor
val token2 = "4567"
val wfp = WatchFacePushManagerFactory.createWatchFacePushManager(context)
with(wfp) {
val slot = addWatchFace(wf1, token1)
setWatchFaceAsActive(slot.slotId)
updateWatchFace(slot.slotId, wf2, token2)
removeWatchFace(slot.slotId)
}
Summary
Nested types |
|---|
public final class WatchFacePushManager.AddWatchFaceException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.IsWatchFaceActiveException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.ListWatchFacesException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.ListWatchFacesResponseRepresents the response from listing watch faces. |
public final class WatchFacePushManager.RemoveWatchFaceException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.SetWatchFaceAsActiveException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.UpdateWatchFaceException extends ExceptionAn exception that can be thrown by |
public final class WatchFacePushManager.WatchFaceDetailsDetails about a watch face that is installed through this API. |
Public methods |
|
|---|---|
abstract @NonNull WatchFacePushManager.WatchFaceDetails |
addWatchFace(Adds a new watch face. |
abstract boolean |
isWatchFaceActive(@NonNull String watchfacePackageName)Checks if a watch face with the given package name is active. |
abstract @NonNull WatchFacePushManager.ListWatchFacesResponse |
Lists all watch faces that were added by the app invoking this method. |
abstract void |
removeWatchFace(@NonNull String slotId)Removes an existing watch face that was previously added by this application. |
abstract void |
setWatchFaceAsActive(@NonNull String slotId)Sets a watch face with the given slot ID as the active watch face. |
abstract @NonNull WatchFacePushManager.WatchFaceDetails |
updateWatchFace(Updates a watch face slot with a new watch face. |
Public methods
addWatchFace
abstract @NonNull WatchFacePushManager.WatchFaceDetails addWatchFace(
@NonNull ParcelFileDescriptor apkFd,
@NonNull String validationToken
)
Adds a new watch face. On success, the given watch face will be available in the watch face carousel on the watch. Note that calling this method will not change the currently active watch face. See also setWatchFaceAsActive.
| Parameters | |
|---|---|
@NonNull ParcelFileDescriptor apkFd |
The |
@NonNull String validationToken |
A token proving that the watch face has gone through the required validation checks. |
| Returns | |
|---|---|
@NonNull WatchFacePushManager.WatchFaceDetails |
The |
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.AddWatchFaceException |
if there is an error while adding the watch face. This could happen if the provided APK is malformed, the validation token is invalid, or if the Watch Face Push service on the watch cannot be accessed. See |
isWatchFaceActive
abstract boolean isWatchFaceActive(@NonNull String watchfacePackageName)
Checks if a watch face with the given package name is active. This method can only be used to check the active status of watch faces installed by this application.
| Returns | |
|---|---|
boolean |
|
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.IsWatchFaceActiveException |
if there is an error while checking if the watch face is active. This could happen if the provided |
listWatchFaces
abstract @NonNull WatchFacePushManager.ListWatchFacesResponse listWatchFaces()
Lists all watch faces that were added by the app invoking this method. Watch faces added by other apps will not be included in the response.
| Returns | |
|---|---|
@NonNull WatchFacePushManager.ListWatchFacesResponse |
A |
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.ListWatchFacesException |
if there is an error while retrieving the watch faces. This could happen if the Watch Face Push service on the watch cannot be accessed. See |
removeWatchFace
abstract void removeWatchFace(@NonNull String slotId)
Removes an existing watch face that was previously added by this application. On success, the watch face will no longer be available in the watch face carousel on the watch. Note that this method can be used to remove the currently active watch face - in that case, the watch will revert to one of the other existing watch faces. Watch faces added by other apps or pre-existing on the device cannot be removed using this method.
| Parameters | |
|---|---|
@NonNull String slotId |
The unique identifier of the watch face to be removed. This ID corresponds to the |
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.RemoveWatchFaceException |
if there is an error while removing the watch face. This could happen if the provided |
| See also | |
|---|---|
addWatchFace |
setWatchFaceAsActive
abstract void setWatchFaceAsActive(@NonNull String slotId)
Sets a watch face with the given slot ID as the active watch face. This method can only be used to set watch faces installed by this application as active.
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.SetWatchFaceAsActiveException |
if there is an error while setting the watch face as active. This could happen if the provided |
updateWatchFace
abstract @NonNull WatchFacePushManager.WatchFaceDetails updateWatchFace(
@NonNull String slotId,
@NonNull ParcelFileDescriptor apkFd,
@NonNull String validationToken
)
Updates a watch face slot with a new watch face. Watch faces added by other apps or already existing on the device cannot be updated using this method. The new watch face could be a newer version of the existing watch face or a completely different watch face. If the slot is updated with a watch face that has the same package name as the existing watch face, all the associated user configuration settings of the watch face will be preserved. If the package name is different, the user configuration settings will be reset to the default values.
| Parameters | |
|---|---|
@NonNull String slotId |
The slot ID to update. |
@NonNull ParcelFileDescriptor apkFd |
The |
@NonNull String validationToken |
A token proving that the watch face has gone through the required validation checks. |
| Returns | |
|---|---|
@NonNull WatchFacePushManager.WatchFaceDetails |
The |
| Throws | |
|---|---|
androidx.wear.watchfacepush.WatchFacePushManager.UpdateWatchFaceException |
if there is an error while updating the watch face. This could happen if the provided APK is malformed, the validation token is invalid, or if the Watch Face Push service on the watch cannot be accessed. See |