# CanvasWatchFaceService.Engine

Summary:[Ctors](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine#pubctors)\|[Methods](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine#inhmethods)  

# CanvasWatchFaceService.Engine

`
public


class
CanvasWatchFaceService.Engine
`  
`


``


``

extends `[WatchFaceService.Engine](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html)`


``


`

|---|---|---|------------------------------------------------------------------|
| [java.lang.Object](http://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [android.service.wallpaper.WallpaperService.Engine](http://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html) |||
|   | ↳ | [android.support.wearable.watchface.WatchFaceService.Engine](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html) ||
|   |   | ↳ | android.support.wearable.watchface.CanvasWatchFaceService.Engine |

<br />

*** ** * ** ***

<br />

**This class is deprecated.**   
Use[Watch Face Format](https://developer.android.com/training/wearables/wff)APIs instead.

The actual implementation of a watch face that draws on a[Canvas](http://developer.android.com/reference/android/graphics/Canvas.html). You must implement[CanvasWatchFaceService.onCreateEngine()](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.html#onCreateEngine())to return your concrete Engine implementation.

## Summary

|                                                                           ### Public constructors                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Engine](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#Engine())`() `                                 |
| ` `[Engine](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#Engine(boolean))`(boolean useHardwareCanvas) ` |

|                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                      ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[invalidate](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#invalidate())`() ` Schedules a call to[onDraw(Canvas, Rect)](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDraw(android.graphics.Canvas,%20android.graphics.Rect))to draw the next frame.                           |
| ` void` | ` `[onDestroy](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDestroy())`() `                                                                                                                                                                                                                                                                      |
| ` void` | ` `[onDraw](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDraw(android.graphics.Canvas,%20android.graphics.Rect))`(`[Canvas](http://developer.android.com/reference/android/graphics/Canvas.html)` canvas, `[Rect](http://developer.android.com/reference/android/graphics/Rect.html)` bounds) ` Draws the watch face.                            |
| ` void` | ` `[onSurfaceChanged](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onSurfaceChanged(android.view.SurfaceHolder,%20int,%20int,%20int))`(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` holder, int format, int width, int height) `                                                                      |
| ` void` | ` `[onSurfaceCreated](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onSurfaceCreated(android.view.SurfaceHolder))`(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` holder) `                                                                                                                              |
| ` void` | ` `[onSurfaceRedrawNeeded](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onSurfaceRedrawNeeded(android.view.SurfaceHolder))`(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` holder) `                                                                                                                    |
| ` void` | ` `[onVisibilityChanged](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onVisibilityChanged(boolean))`(boolean visible) ` Called to inform you of the watch face becoming visible or hidden.                                                                                                                                                         |
| ` void` | ` `[postInvalidate](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#postInvalidate())`() ` Posts a message to schedule a call to[onDraw(Canvas, Rect)](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDraw(android.graphics.Canvas,%20android.graphics.Rect))to draw the next frame. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.support.wearable.watchface.WatchFaceService.Engine](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html)` ` |------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` final int`                                                                       | ` `[getInterruptionFilter](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#getInterruptionFilter())`() ` Returns interruption filter selected by the user.                                                                                                                                                                                                                                                     | | ` final int`                                                                       | ` `[getNotificationCount](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#getNotificationCount())`() ` Returns the total number of notification cards in the stream.                                                                                                                                                                                                                                           | | ` final `[Rect](http://developer.android.com/reference/android/graphics/Rect.html) | ` `[getPeekCardPosition](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#getPeekCardPosition())`() ` *This method is deprecated. Wear 2.0 doesn't have peeking cards*                                                                                                                                                                                                                                          | | ` final int`                                                                       | ` `[getUnreadCount](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#getUnreadCount())`() ` Returns the number of unread notification cards in the stream.                                                                                                                                                                                                                                                      | | ` final boolean`                                                                   | ` `[isInAmbientMode](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#isInAmbientMode())`() ` Returns whether the watch face is in ambient mode.                                                                                                                                                                                                                                                                | | ` void`                                                                            | ` `[onAmbientModeChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onAmbientModeChanged(boolean))`(boolean inAmbientMode) ` Called when the device enters or exits ambient mode.                                                                                                                                                                                                                        | | ` `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)         | ` `[onCommand](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onCommand(java.lang.String,%20int,%20int,%20int,%20android.os.Bundle,%20boolean))`(`[String](http://developer.android.com/reference/java/lang/String.html)` action, int x, int y, int z, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` extras, boolean resultRequested) `                                           | | ` void`                                                                            | ` `[onComplicationDataUpdate](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onComplicationDataUpdate(int,%20android.support.wearable.complications.ComplicationData))`(int watchFaceComplicationId, `[ComplicationData](https://developer.android.com/reference/android/support/wearable/complications/ComplicationData.html)` data) ` Called when new complication data is received.                        | | ` void`                                                                            | ` `[onCreate](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onCreate(android.view.SurfaceHolder))`(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` holder) `                                                                                                                                                                                                       | | ` void`                                                                            | ` `[onDestroy](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onDestroy())`() `                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                            | ` `[onInterruptionFilterChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onInterruptionFilterChanged(int))`(int interruptionFilter) ` Called when the user changes interruption filter.                                                                                                                                                                                                                | | ` void`                                                                            | ` `[onNotificationCountChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onNotificationCountChanged(int))`(int count) ` Called when the total number of notification cards in the stream has changed.                                                                                                                                                                                                   | | ` void`                                                                            | ` `[onPeekCardPositionUpdate](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onPeekCardPositionUpdate(android.graphics.Rect))`(`[Rect](http://developer.android.com/reference/android/graphics/Rect.html)` rect) ` *This method is deprecated. Wear 2.0 doesn't have peeking cards*                                                                                                                           | | ` void`                                                                            | ` `[onPropertiesChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onPropertiesChanged(android.os.Bundle))`(`[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` properties) ` Called when the properties of the device are determined.                                                                                                                                             | | ` void`                                                                            | ` `[onTapCommand](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onTapCommand(int,%20int,%20int,%20long))`(int tapType, int x, int y, long eventTime) ` Called when a tap or touch related event occurs.                                                                                                                                                                                                      | | ` void`                                                                            | ` `[onTimeTick](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onTimeTick())`() ` Called periodically to update the time shown by the watch face.                                                                                                                                                                                                                                                             | | ` void`                                                                            | ` `[onTouchEvent](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onTouchEvent(android.view.MotionEvent))`(`[MotionEvent](http://developer.android.com/reference/android/view/MotionEvent.html)` event) ` *This method is deprecated. Do not use this to receive touch events on a watch face.*                                                                                                                | | ` void`                                                                            | ` `[onUnreadCountChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onUnreadCountChanged(int))`(int count) ` Called when the number of unread notification cards in the stream has changed.                                                                                                                                                                                                              | | ` void`                                                                            | ` `[onVisibilityChanged](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onVisibilityChanged(boolean))`(boolean visible) ` Called to inform you of the watch face becoming visible or hidden.                                                                                                                                                                                                                  | | ` void`                                                                            | ` `[setActiveComplications](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#setActiveComplications(int...))`(int... watchFaceComplicationIds) ` Sets the complications which are active in the watchface.                                                                                                                                                                                                      | | ` void`                                                                            | ` `[setDefaultComplicationProvider](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#setDefaultComplicationProvider(int,%20android.content.ComponentName,%20int))`(int watchFaceComplicationId, `[ComponentName](http://developer.android.com/reference/android/content/ComponentName.html)` provider, int type) ` Sets a custom provider as the default provider for the specified watch face complication id. | | ` void`                                                                            | ` `[setDefaultSystemComplicationProvider](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#setDefaultSystemComplicationProvider(int,%20int,%20int))`(int watchFaceComplicationId, int systemProvider, int type) ` Sets a system provider as the default provider for the specified watch face complication id.                                                                                                  | | ` void`                                                                            | ` `[setTouchEventsEnabled](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#setTouchEventsEnabled(boolean))`(boolean enabled) ` *This method is deprecated. Do not use this to receive touch events on a watch face.*                                                                                                                                                                                           | | ` void`                                                                            | ` `[setWatchFaceStyle](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#setWatchFaceStyle(android.support.wearable.watchface.WatchFaceStyle))`(`[WatchFaceStyle](https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceStyle.html)` watchFaceStyle) ` Sets the watch face style.                                                                                                  | ||
| From class` `[android.service.wallpaper.WallpaperService.Engine](http://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html)` ` |--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                    | ` dump(`[String](http://developer.android.com/reference/java/lang/String.html)` arg0, `[FileDescriptor](http://developer.android.com/reference/java/io/FileDescriptor.html)` arg1, `[PrintWriter](http://developer.android.com/reference/java/io/PrintWriter.html)` arg2, `[String[]](http://developer.android.com/reference/java/lang/String.html)` arg3) ` | | ` int`                                                                                     | ` getDesiredMinimumHeight() `                                                                                                                                                                                                                                                                                                                                | | ` int`                                                                                     | ` getDesiredMinimumWidth() `                                                                                                                                                                                                                                                                                                                                 | | ` `[Context](http://developer.android.com/reference/android/content/Context.html)          | ` getDisplayContext() `                                                                                                                                                                                                                                                                                                                                      | | ` `[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html) | ` getSurfaceHolder() `                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                 | ` isPreview() `                                                                                                                                                                                                                                                                                                                                              | | ` boolean`                                                                                 | ` isVisible() `                                                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                    | ` notifyColorsChanged() `                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                    | ` onApplyWindowInsets(`[WindowInsets](http://developer.android.com/reference/android/view/WindowInsets.html)` arg0) `                                                                                                                                                                                                                                        | | ` `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)                 | ` onCommand(`[String](http://developer.android.com/reference/java/lang/String.html)` arg0, int arg1, int arg2, int arg3, `[Bundle](http://developer.android.com/reference/android/os/Bundle.html)` arg4, boolean arg5) `                                                                                                                                     | | ` WallpaperColors`                                                                         | ` onComputeColors() `                                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                    | ` onCreate(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` arg0) `                                                                                                                                                                                                                                                 | | ` void`                                                                                    | ` onDesiredSizeChanged(int arg0, int arg1) `                                                                                                                                                                                                                                                                                                                 | | ` void`                                                                                    | ` onDestroy() `                                                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                    | ` onOffsetsChanged(float arg0, float arg1, float arg2, float arg3, int arg4, int arg5) `                                                                                                                                                                                                                                                                     | | ` void`                                                                                    | ` onSurfaceChanged(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` arg0, int arg1, int arg2, int arg3) `                                                                                                                                                                                                           | | ` void`                                                                                    | ` onSurfaceCreated(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` arg0) `                                                                                                                                                                                                                                         | | ` void`                                                                                    | ` onSurfaceDestroyed(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` arg0) `                                                                                                                                                                                                                                       | | ` void`                                                                                    | ` onSurfaceRedrawNeeded(`[SurfaceHolder](http://developer.android.com/reference/android/view/SurfaceHolder.html)` arg0) `                                                                                                                                                                                                                                    | | ` void`                                                                                    | ` onTouchEvent(`[MotionEvent](http://developer.android.com/reference/android/view/MotionEvent.html)` arg0) `                                                                                                                                                                                                                                                 | | ` void`                                                                                    | ` onVisibilityChanged(boolean arg0) `                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                    | ` onZoomChanged(float arg0) `                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                    | ` setOffsetNotificationsEnabled(boolean arg0) `                                                                                                                                                                                                                                                                                                              | | ` void`                                                                                    | ` setTouchEventsEnabled(boolean arg0) `                                                                                                                                                                                                                                                                                                                      | ||
| From class` `[java.lang.Object](http://developer.android.com/reference/java/lang/Object.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` `[Object](http://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                               | | ` boolean`                                                                         | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                            | ` finalize() `                                                                            | | ` final `[Class](http://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                            | | ` int`                                                                             | ` hashCode() `                                                                            | | ` final void`                                                                      | ` notify() `                                                                              | | ` final void`                                                                      | ` notifyAll() `                                                                           | | ` `[String](http://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                            | | ` final void`                                                                      | ` wait(long arg0, int arg1) `                                                             | | ` final void`                                                                      | ` wait(long arg0) `                                                                       | | ` final void`                                                                      | ` wait() `                                                                                | ||

## Public constructors

### Engine

```
public Engine ()
```

<br />

<br />

### Engine

```
public Engine (boolean useHardwareCanvas)
```

<br />

<br />

|              Parameters               ||
|---------------------|------------------|
| `useHardwareCanvas` | `boolean` <br /> |

## Public methods

### invalidate

```
public void invalidate ()
```

Schedules a call to[onDraw(Canvas, Rect)](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDraw(android.graphics.Canvas,%20android.graphics.Rect))to draw the next frame. Must be called on the main thread.

<br />

### onDestroy

```
public void onDestroy ()
```

<br />

<br />

### onDraw

```
public void onDraw (Canvas canvas, 
                Rect bounds)
```

Draws the watch face.

<br />

|                                                                                                              Parameters                                                                                                               ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `canvas` | `Canvas`: the canvas to draw into.[Canvas.isHardwareAccelerated()](http://developer.android.com/reference/android/graphics/Canvas.html#isHardwareAccelerated())can be used to confirm if it is hardware accelerated. <br /> |
| `bounds` | `Rect`: the bounds in which the watch face should be drawn <br />                                                                                                                                                           |

### onSurfaceChanged

```
public void onSurfaceChanged (SurfaceHolder holder, 
                int format, 
                int width, 
                int height)
```

<br />

<br />

|            Parameters            ||
|----------|------------------------|
| `holder` | `SurfaceHolder` <br /> |
| `format` | `int` <br />           |
| `width`  | `int` <br />           |
| `height` | `int` <br />           |

### onSurfaceCreated

```
public void onSurfaceCreated (SurfaceHolder holder)
```

<br />

<br />

|            Parameters            ||
|----------|------------------------|
| `holder` | `SurfaceHolder` <br /> |

### onSurfaceRedrawNeeded

```
public void onSurfaceRedrawNeeded (SurfaceHolder holder)
```

<br />

<br />

|            Parameters            ||
|----------|------------------------|
| `holder` | `SurfaceHolder` <br /> |

### onVisibilityChanged

```
public void onVisibilityChanged (boolean visible)
```

Called to inform you of the watch face becoming visible or hidden. If you decide to override this method, you*must* call`super.onVisibilityChanged(visible)`as the first statement in your override.

<br />

|         Parameters          ||
|-----------|------------------|
| `visible` | `boolean` <br /> |

### postInvalidate

```
public void postInvalidate ()
```

Posts a message to schedule a call to[onDraw(Canvas, Rect)](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#onDraw(android.graphics.Canvas,%20android.graphics.Rect))to draw the next frame. Unlike[invalidate()](https://developer.android.com/reference/android/support/wearable/watchface/CanvasWatchFaceService.Engine.html#invalidate()), this method is thread-safe and may be called on any thread.

<br />