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()
|
|
CanvasWatchFaceService.Engine(boolean useHardwareCanvas)
|
Public methods | |
---|---|
void
|
invalidate()
Schedules a call to |
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
|
onVisibilityChanged(boolean visible)
Called to inform you of the watch face becoming visible or hidden. |
void
|
postInvalidate()
Posts a message to schedule a call to |
Inherited methods | |
---|---|
![]()
android.support.wearable.watchface.WatchFaceService.Engine
| |
![]()
android.service.wallpaper.WallpaperService.Engine
| |
![]()
java.lang.Object
|
Public constructors
CanvasWatchFaceService.Engine
CanvasWatchFaceService.Engine ()
CanvasWatchFaceService.Engine
CanvasWatchFaceService.Engine (boolean useHardwareCanvas)
Parameters | |
---|---|
useHardwareCanvas |
boolean |
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. isHardwareAccelerated() can be used to
confirm if it is hardware accelerated. |
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 |
onSurfaceRedrawNeeded
void onSurfaceRedrawNeeded (SurfaceHolder holder)
Parameters | |
---|---|
holder |
SurfaceHolder |
onVisibilityChanged
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.
Parameters | |
---|---|
visible |
boolean |
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.