Writing your own watch face
Android Studio is the primary tool that we use to write Wear apps for numerous reasons; since we have already configured our development environment for Wear 2.0 development, it shouldn't be a challenge. Let's fire up Android Studio and create a Wear project.
In Activity chooser, select Add No Activity
. Since a watch face is a service, we don't need activity:
We have read in the previous section that we will be extending the class to CanvasWatchFaceService
, where watch face is being drawn on a canvas, and another class is CanvasWatchFaceService.Engine
, where we will work on the actual implementation of the watch face and more methods that we have discussed. It will help us to achieve the necessary setup for the watch face.
Now, let's create a class file called PacktWatchFace
in the package.
The PacktWatchFace
class will extend to the CanvasWatchFaceService
class:
After creating the class file, extend it to the CanvasWatchFaceService
class; this is the service class...