Note: The Wearable Support Library classes under the android.support.wearable
package are subject to change. For the full Android API reference, see Reference.
java.lang.Object | |||||
↳ | android.content.Context | ||||
↳ | android.content.ContextWrapper | ||||
↳ | android.app.Service | ||||
↳ | android.service.wallpaper.WallpaperService | ||||
↳ | android.support.wearable.watchface.WatchFaceService |
Known Direct Subclasses |
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 in ambient mode 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. |
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.
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.service.wallpaper.WallpaperService
| |||||||||||
From class
android.app.Service
| |||||||||||
From class
android.content.Context
| |||||||||||
From interface
android.content.ComponentCallbacks2
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.service.wallpaper.WallpaperService
| |||||||||||
From class
android.app.Service
| |||||||||||
From class
android.content.ContextWrapper
| |||||||||||
From class
android.content.Context
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.content.ComponentCallbacks2
| |||||||||||
From interface
android.content.ComponentCallbacks
|
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.