WatchState

public final class WatchState


Describes the current state of the wearable including some hardware details such as whether or not it supports burn in prevention and low-bit ambient.

Summary

Public constructors

WatchState(
    @NonNull StateFlow<Integer> interruptionFilter,
    @NonNull StateFlow<Boolean> isAmbient,
    @NonNull StateFlow<Boolean> isBatteryLowAndNotCharging,
    @NonNull StateFlow<Boolean> isVisible,
    boolean hasLowBitAmbient,
    boolean hasBurnInProtection,
    long analogPreviewReferenceTimeMillis,
    long digitalPreviewReferenceTimeMillis,
    int chinHeight,
    boolean isHeadless
)

This method is deprecated. WatchState constructors without watchFaceInstanceId are deprecated

WatchState(
    @NonNull StateFlow<Integer> interruptionFilter,
    @NonNull StateFlow<Boolean> isAmbient,
    @NonNull StateFlow<Boolean> isBatteryLowAndNotCharging,
    @NonNull StateFlow<Boolean> isVisible,
    boolean hasLowBitAmbient,
    boolean hasBurnInProtection,
    long analogPreviewReferenceTimeMillis,
    long digitalPreviewReferenceTimeMillis,
    @Px int chinHeight,
    boolean isHeadless,
    @NonNull StateFlow<@NonNull String> watchFaceInstanceId
)

Public methods

final long

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

final @Px int

the size, in pixels, of the chin or zero if the device does not have a chin.

final long

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

final @NonNull StateFlow<Integer>

The current user interruption settings.

final @NonNull StateFlow<@NonNull String>

The ID associated with the watch face instance.

final boolean

Whether or not the watch hardware supports burn in protection.

final boolean

Whether or not the watch hardware supports low bit ambient support.

final @NonNull StateFlow<Boolean>

Whether or not the watch is in ambient mode.

final @NonNull StateFlow<Boolean>

Whether or not we should conserve power due to a low battery which isn't charging.

final boolean

Whether or not this is a headless watchface.

final @NonNull StateFlow<Boolean>

Whether or not the watch face is visible.

Public constructors

WatchState

Added in 1.0.0
Deprecated in 1.1.0
public WatchState(
    @NonNull StateFlow<Integer> interruptionFilter,
    @NonNull StateFlow<Boolean> isAmbient,
    @NonNull StateFlow<Boolean> isBatteryLowAndNotCharging,
    @NonNull StateFlow<Boolean> isVisible,
    boolean hasLowBitAmbient,
    boolean hasBurnInProtection,
    long analogPreviewReferenceTimeMillis,
    long digitalPreviewReferenceTimeMillis,
    int chinHeight,
    boolean isHeadless
)

WatchState

Added in 1.1.0
public WatchState(
    @NonNull StateFlow<Integer> interruptionFilter,
    @NonNull StateFlow<Boolean> isAmbient,
    @NonNull StateFlow<Boolean> isBatteryLowAndNotCharging,
    @NonNull StateFlow<Boolean> isVisible,
    boolean hasLowBitAmbient,
    boolean hasBurnInProtection,
    long analogPreviewReferenceTimeMillis,
    long digitalPreviewReferenceTimeMillis,
    @Px int chinHeight,
    boolean isHeadless,
    @NonNull StateFlow<@NonNull String> watchFaceInstanceId
)
Parameters
@NonNull StateFlow<Integer> interruptionFilter

The current user interruption settings. See NotificationManager. This is initially null because the watch face is created before the system has sent the state. Based on the value the watch face should adjust the amount of information it displays. For example, if it displays the number of pending emails, it should hide it if interruptionFilter is equal to NotificationManager.INTERRUPTION_FILTER_NONE. interruptionFilter can be NotificationManager.INTERRUPTION_FILTER_NONE, NotificationManager.INTERRUPTION_FILTER_PRIORITY, NotificationManager.INTERRUPTION_FILTER_ALL, NotificationManager.INTERRUPTION_FILTER_ALARMS, or NotificationManager.INTERRUPTION_FILTER_UNKNOWN.

@NonNull StateFlow<Boolean> isAmbient

Whether or not the watch is in ambient mode. This is initially null because the watch face is created before the system has sent the state. The order in which ambient vs style changes are reported is not guaranteed. Likewise the order of isAmbient flow callbacks and Renderer.CanvasRenderer.render or Renderer.GlesRenderer.render calls is not defined. For rendering please refer to RenderParameters.drawMode instead of isAmbient because you might receive requests for rendering non-ambient frames while the watch is ambient (e.g. editing from the companion phone).

@NonNull StateFlow<Boolean> isBatteryLowAndNotCharging

Whether or not we should conserve power due to a low battery which isn't charging. This is initially null because the watch face is created before the system has sent the state. Only valid if android.support.wearable.watchface.WatchFaceStyle.hideNotificationIndicator is true.

@NonNull StateFlow<Boolean> isVisible

Whether or not the watch face is visible. This is initially null because the watch face is created before the system has sent the state.

boolean hasLowBitAmbient

Whether or not the watch hardware supports low bit ambient support.

boolean hasBurnInProtection

Whether or not the watch hardware supports burn in protection.

long analogPreviewReferenceTimeMillis

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

long digitalPreviewReferenceTimeMillis

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

@Px int chinHeight

the size, in pixels, of the chin or zero if the device does not have a chin. A chin is a section at the bottom of a circular display that is visible due to hardware limitations.

boolean isHeadless

Whether or not this is a headless watchface.

@NonNull StateFlow<@NonNull String> watchFaceInstanceId

The ID associated with the watch face instance. Note there may be more than one instance associated with a WatchFaceService. See androidx.wear.watchface.client.WatchFaceId for more details.

Public methods

getAnalogPreviewReferenceTimeMillis

Added in 1.0.0
public final long getAnalogPreviewReferenceTimeMillis()

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

getChinHeight

Added in 1.0.0
public final @Px int getChinHeight()

the size, in pixels, of the chin or zero if the device does not have a chin. A chin is a section at the bottom of a circular display that is visible due to hardware limitations.

getDigitalPreviewReferenceTimeMillis

Added in 1.0.0
public final long getDigitalPreviewReferenceTimeMillis()

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

getInterruptionFilter

Added in 1.0.0
public final @NonNull StateFlow<IntegergetInterruptionFilter()

The current user interruption settings. See NotificationManager. This is initially null because the watch face is created before the system has sent the state. Based on the value the watch face should adjust the amount of information it displays. For example, if it displays the number of pending emails, it should hide it if interruptionFilter is equal to NotificationManager.INTERRUPTION_FILTER_NONE. interruptionFilter can be NotificationManager.INTERRUPTION_FILTER_NONE, NotificationManager.INTERRUPTION_FILTER_PRIORITY, NotificationManager.INTERRUPTION_FILTER_ALL, NotificationManager.INTERRUPTION_FILTER_ALARMS, or NotificationManager.INTERRUPTION_FILTER_UNKNOWN.

getWatchFaceInstanceId

Added in 1.1.0
public final @NonNull StateFlow<@NonNull StringgetWatchFaceInstanceId()

The ID associated with the watch face instance. Note there may be more than one instance associated with a WatchFaceService. See androidx.wear.watchface.client.WatchFaceId for more details.

hasBurnInProtection

Added in 1.2.0
public final boolean hasBurnInProtection()

Whether or not the watch hardware supports burn in protection.

hasLowBitAmbient

Added in 1.2.0
public final boolean hasLowBitAmbient()

Whether or not the watch hardware supports low bit ambient support.

isAmbient

Added in 1.0.0
public final @NonNull StateFlow<BooleanisAmbient()

Whether or not the watch is in ambient mode. This is initially null because the watch face is created before the system has sent the state. The order in which ambient vs style changes are reported is not guaranteed. Likewise the order of isAmbient flow callbacks and Renderer.CanvasRenderer.render or Renderer.GlesRenderer.render calls is not defined. For rendering please refer to RenderParameters.drawMode instead of isAmbient because you might receive requests for rendering non-ambient frames while the watch is ambient (e.g. editing from the companion phone).

isBatteryLowAndNotCharging

Added in 1.1.0
public final @NonNull StateFlow<BooleanisBatteryLowAndNotCharging()

Whether or not we should conserve power due to a low battery which isn't charging. This is initially null because the watch face is created before the system has sent the state. Only valid if android.support.wearable.watchface.WatchFaceStyle.hideNotificationIndicator is true.

isHeadless

Added in 1.0.0
public final boolean isHeadless()

Whether or not this is a headless watchface.

isVisible

Added in 1.0.0
public final @NonNull StateFlow<BooleanisVisible()

Whether or not the watch face is visible. This is initially null because the watch face is created before the system has sent the state.