WatchFaceService

public abstract class WatchFaceService
extends WallpaperService

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:

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 the wake lock permission:

 <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. 

@interface WatchFaceService.TapType

 

Constants

int INTERRUPTION_FILTER_ALARMS

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int).

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).

int INTERRUPTION_FILTER_UNKNOWN

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.

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()

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

INTERRUPTION_FILTER_ALARMS

int INTERRUPTION_FILTER_ALARMS

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int). This value means that the user requested to only be interrupted by alarms.

Constant Value: 4 (0x00000004)

INTERRUPTION_FILTER_ALL

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)

INTERRUPTION_FILTER_NONE

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)

INTERRUPTION_FILTER_PRIORITY

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)

INTERRUPTION_FILTER_UNKNOWN

int INTERRUPTION_FILTER_UNKNOWN

Returned by getInterruptionFilter() and passed to onInterruptionFilterChanged(int). This value means the interruption filter is unavailable.

Constant Value: 0 (0x00000000)

PROPERTY_BURN_IN_PROTECTION

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"

PROPERTY_LOW_BIT_AMBIENT

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"

TAP_TYPE_TAP

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. A TAP_TYPE_TOUCH will always occur first. This event will not occur if a TAP_TYPE_TOUCH_CANCEL is sent.

Constant Value: 2 (0x00000002)

TAP_TYPE_TOUCH

int TAP_TYPE_TOUCH

Used in onTapCommand to indicate a "down" touch event on the watch face.

Constant Value: 0 (0x00000000)

TAP_TYPE_TOUCH_CANCEL

int TAP_TYPE_TOUCH_CANCEL

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.

Constant Value: 1 (0x00000001)

Public constructors

WatchFaceService

WatchFaceService ()

Public methods

onCreateEngine

WatchFaceService.Engine onCreateEngine ()

Returns
WatchFaceService.Engine