java.lang.Object | |||||
↳ | android.content.Context | ||||
↳ | android.content.ContextWrapper | ||||
↳ | android.app.Service | ||||
↳ | android.service.wallpaper.WallpaperService | ||||
↳ | android.support.wearable.watchface.WatchFaceService |
![]() |
A subclass of WallpaperService
with a WallpaperService.Engine
that exposes
callbacks for the lifecycle of a watch face. If you want to create a watch face for a wearable,
you should use this instead of vanilla WallpaperService
.
A watch face service, similarly to a wallpaper service, must implement only one method:
onCreateEngine()
. However, it must also create a subclass of inner class
WatchFaceService.Engine
. Most watch face engines will implement the following
methods:
onTimeTick()
to update the time and refresh the view
onAmbientModeChanged(boolean)
to update ambient mode and refresh the view
Most watch face engines will also implement onInterruptionFilterChanged(int)
to
update the view depending on how much information the user has requested.
For updates that occur in ambient mode a wake lock will be held so the device doesn't go to sleep until the watch face finishes drawing.
Registering watch faces in your application works similarly to registering wallpapers with several additional steps. First, watch faces require two permissions:
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
Second, your watch face service declaration needs preview metadata:
<meta-data android:name="com.google.android.wearable.watchface.preview" android:resource="@drawable/preview_face" /> <meta-data android:name="com.google.android.wearable.watchface.preview_circular" android:resource="@drawable/preview_face_circular" />
Finally, you need to add a special intent filter, so your watch face can be detected:
<intent-filter> <action android:name="android.service.wallpaper.WallpaperService" /> <category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" /> </intent-filter>
For more information consult: https://developer.android.com/training/wearables/watch-faces/index.html
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
WatchFaceService.Engine | The actual implementation of a watch face. | ||||||||||
WatchFaceService.TapType |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INTERRUPTION_FILTER_ALL |
Returned by getInterruptionFilter() and passed to
onInterruptionFilterChanged(int) .
|
|||||||||
int | INTERRUPTION_FILTER_NONE |
Returned by getInterruptionFilter() and passed to
onInterruptionFilterChanged(int) .
|
|||||||||
int | INTERRUPTION_FILTER_PRIORITY |
Returned by getInterruptionFilter() and passed to
onInterruptionFilterChanged(int) .
|
|||||||||
String | PROPERTY_BURN_IN_PROTECTION |
Property in bundle passed to onPropertiesChanged(Bundle) to indicate whether burn-in
protection is required.
|
|||||||||
String | PROPERTY_LOW_BIT_AMBIENT |
Property in bundle passed to onPropertiesChanged(Bundle) to indicate whether the device
has low-bit ambient mode.
|
|||||||||
int | TAP_TYPE_TAP | Used in onTapCommaned to indicate that an "up" event on the watch face has occurred that has not been consumed by another activity. | |||||||||
int | TAP_TYPE_TOUCH | Used in onTapCommand to indicate a "down" touch event on the watch face. | |||||||||
int | TAP_TYPE_TOUCH_CANCEL | Used in onTapCaommand to indicate that a previous TAP_TYPE_TOUCH touch event has been canceled. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Returned by getInterruptionFilter()
and passed to
onInterruptionFilterChanged(int)
. This value means that the user requested to see
all notifications.
Returned by getInterruptionFilter()
and passed to
onInterruptionFilterChanged(int)
. This value means that the user requested not to
see any notifications.
Returned by getInterruptionFilter()
and passed to
onInterruptionFilterChanged(int)
. This value means that the user requested to see
only high priority notifications.
Property in bundle passed to onPropertiesChanged(Bundle)
to indicate whether burn-in
protection is required. When this property is set to true, views are shifted around
periodically in ambient mode. To ensure that content isn't shifted off the screen, watch
faces should avoid placing content within 10 pixels of the edge of the screen. Watch faces
should also avoid solid white areas to prevent pixel burn-in. Both of these requirements only
apply in ambient mode, and only when this property is set to true.
Property in bundle passed to onPropertiesChanged(Bundle)
to indicate whether the device
has low-bit ambient mode. When this property is set to true, the screen supports fewer bits
for each color in ambient mode. In this case, watch faces should disable anti-aliasing in
ambient mode.
Used in onTapCommaned to indicate that an "up" event on the watch face has occurred that has not been consumed by another activity. A TAP_TYPE_TOUCH will always occur first. This event will not occur if a TAP_TYPE_TOUCH_CANCEL is sent.
Used in onTapCommand to indicate a "down" touch event on the watch face.
Used in onTapCaommand to indicate that a previous TAP_TYPE_TOUCH touch event has been canceled. This generally happens when the watch face is touched but then a move or long press occurs.