It's time to see the concepts, introduced previously, in action. We will build a simple watch face that shows the time using a fairly standard hour, minutes, and seconds display. Tapping the watch face will show the number of days that have elapsed in the current year. A second tap will show the number of days remaining in the current year.
In the subsections that follow, we will define a WatchFaceService
class that extends the API CanvasWatchFaceService
class and overrides the relevant event handlers that pertain to our sample application.
We begin by declaring the TodayWatchFaceService
service and the WatchFaceConfigActivity
activity, which helps with selecting a background color for the watch:
<!— Required to act as a custom watch face. —> <uses-permission android:name="android.permission.WAKE_LOCK" /> <service android:name=".TodayWatchFaceService" android:label="@string/digital_name" android:permission="android...