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


This class is deprecated.
Use Watch Face Format APIs instead.

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

This class is deprecated. Use Watch Face Format APIs instead.  

@interface WatchFaceService.TapType

 

Constants

int INTERRUPTION_FILTER_ALARMS

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

int INTERRUPTION_FILTER_ALL

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

int INTERRUPTION_FILTER_NONE

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

int INTERRUPTION_FILTER_PRIORITY

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

int INTERRUPTION_FILTER_UNKNOWN

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

String PROPERTY_BURN_IN_PROTECTION

Property in bundle passed to WatchFaceService.Engine.onPropertiesChanged(Bundle) to indicate whether burn-in protection is required.

String PROPERTY_LOW_BIT_AMBIENT

Property in bundle passed to WatchFaceService.Engine.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

Public constructors

WatchFaceService()

Public methods

abstract WatchFaceService.Engine onCreateEngine()

Inherited methods

Constants

INTERRUPTION_FILTER_ALARMS

public static final int INTERRUPTION_FILTER_ALARMS

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

Constant Value: 4 (0x00000004)

INTERRUPTION_FILTER_ALL

public static final int INTERRUPTION_FILTER_ALL

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

Constant Value: 1 (0x00000001)

INTERRUPTION_FILTER_NONE

public static final int INTERRUPTION_FILTER_NONE

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

Constant Value: 3 (0x00000003)

INTERRUPTION_FILTER_PRIORITY

public static final int INTERRUPTION_FILTER_PRIORITY

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

Constant Value: 2 (0x00000002)

INTERRUPTION_FILTER_UNKNOWN

public static final int INTERRUPTION_FILTER_UNKNOWN

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

Constant Value: 0 (0x00000000)

PROPERTY_BURN_IN_PROTECTION

public static final String PROPERTY_BURN_IN_PROTECTION

Property in bundle passed to WatchFaceService.Engine.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

public static final String PROPERTY_LOW_BIT_AMBIENT

Property in bundle passed to WatchFaceService.Engine.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

public static final 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

public static final 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

public static final 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

public WatchFaceService ()

Public methods

onCreateEngine

public abstract WatchFaceService.Engine onCreateEngine ()

Returns
WatchFaceService.Engine