public abstract class

WatchFaceService

extends WallpaperService

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

Class Overview

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:

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

Summary

Nested Classes
class 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
WatchFaceService()
Public Methods
abstract WatchFaceService.Engine onCreateEngine()
[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

Constants

public static final int INTERRUPTION_FILTER_ALL

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int). This value means that the user requested to see all notifications.

Constant Value: 1 (0x00000001)

public static final int INTERRUPTION_FILTER_NONE

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int). This value means that the user requested not to see any notifications.

Constant Value: 3 (0x00000003)

public static final int INTERRUPTION_FILTER_PRIORITY

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int). This value means that the user requested to see only high priority notifications.

Constant Value: 2 (0x00000002)

public static final String PROPERTY_BURN_IN_PROTECTION

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.

Constant Value: "burn_in_protection"

public static final String PROPERTY_LOW_BIT_AMBIENT

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.

Constant Value: "low_bit_ambient"

Public Constructors

public WatchFaceService ()

Public Methods

public abstract WatchFaceService.Engine onCreateEngine ()