Android wearables are far more than just watches, but they still need to perform the basic task of presenting the user with the current time.
Although, automatically installed when creating a new Android Wear project, we do need to have the Xamarin.Android.Wear NuGet installed in the wearable project.
Creating a watch face consists of creating two parts. The first is the rendering engine, which inherits from one of the WatchFaceService.Engine
types, and the other is WatchFaceService
, which manages it:
We need to specify the permissions for both the handheld and wearable apps. The handheld does not require any activities, but just requires the permissions to be set:
[assembly: UsesPermission(Manifest.Permission.WakeLock)] [assembly: UsesPermission( "com.google.android.permission.PROVIDE_BACKGROUND")]
For our watch face, we use
CanvasWatchFaceService.Engine
as our base type. In the constructor, we keep a reference toCanvasWatchFaceService
because...