Skip to content

Most visited

Recently visited

navigation

CanvasWatchFaceService.Engine

public class CanvasWatchFaceService.Engine
extends WatchFaceService.Engine

java.lang.Object
   ↳ android.service.wallpaper.WallpaperService.Engine
     ↳ android.support.wearable.watchface.WatchFaceService.Engine
       ↳ android.support.wearable.watchface.CanvasWatchFaceService.Engine


The actual implementation of a watch face that draws on a Canvas. You must implement onCreateEngine() to return your concrete Engine implementation.

Summary

Public constructors

CanvasWatchFaceService.Engine()

Public methods

void invalidate()

Schedules a call to onDraw(Canvas, Rect) to draw the next frame.

void onDestroy()
void onDraw(Canvas canvas, Rect bounds)

Draws the watch face.

void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)
void onSurfaceCreated(SurfaceHolder holder)
void onSurfaceRedrawNeeded(SurfaceHolder holder)
void postInvalidate()

Posts a message to schedule a call to onDraw(Canvas, Rect) to draw the next frame.

Inherited methods

From class android.support.wearable.watchface.WatchFaceService.Engine
From class android.service.wallpaper.WallpaperService.Engine
From class java.lang.Object

Public constructors

CanvasWatchFaceService.Engine

CanvasWatchFaceService.Engine ()

Public methods

invalidate

void invalidate ()

Schedules a call to onDraw(Canvas, Rect) to draw the next frame. Must be called on the main thread.

onDestroy

void onDestroy ()

onDraw

void onDraw (Canvas canvas, 
                Rect bounds)

Draws the watch face.

Parameters
canvas Canvas: the canvas to draw into

bounds Rect: the bounds in which the watch face should be drawn

onSurfaceChanged

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

Parameters
holder SurfaceHolder

format int

width int

height int

onSurfaceCreated

void onSurfaceCreated (SurfaceHolder holder)

Parameters
holder SurfaceHolder

onSurfaceRedrawNeeded

void onSurfaceRedrawNeeded (SurfaceHolder holder)

Parameters
holder SurfaceHolder

postInvalidate

void postInvalidate ()

Posts a message to schedule a call to onDraw(Canvas, Rect) to draw the next frame. Unlike invalidate(), this method is thread-safe and may be called on any thread.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)