Reputation: 38
I've had a lot of frustration trying to develop a Watch face for Android Wear.
First I got my watch face to function as I wanted, and used the default Service code to make sure it was working properly.
Then I wanted to change the UI. I made round and rect xml file, as well as the activity watch face xml that uses WatchViewStub. I realized that I made a mistake - this seems to only work with an Activity.
My question is - when would you use an Activity over a Service? The android developer docs say "Watch faces in Android Wear are implemented as services and packaged inside a wearable app"- https://developer.android.com/training/wearables/watch-faces/service.html I'm just confused as to whether I need to implement my watch face as a Service or as an Activity?
Upvotes: 0
Views: 218
Reputation: 42208
You need to implement your watch face as a Service
.
To be more precise, you need to implement a subclass of WatchFaceService
, which is subclass of WallpaperService
.
You can find more information here: https://developer.android.com/training/wearables/watch-faces/index.html
Upvotes: 2
Reputation: 200060
The only option for building a watch face using the Watch Face APIs is via a service.
You can override the onApplyWindowInsets() method and call isRound() to determine if you are running on a round device, changing what you draw in onDraw()
accordingly.
Upvotes: 0