Using the Complications API there's an icon type, but when it comes to drawing the icon I'm not sure how to do it.
When I'm drawing the actual watch face there doesn't seem to be a drawIcon method. E.g. something like canvas.drawIcon(icon). I can only see how to draw a bitmap.
In my drawComplications method I have this:
} else if (complicationData.getType() == ComplicationData.TYPE_ICON) {
Icon icon = complicationData.getIcon();
How do I then draw the icon to the canvas?
The code lab here doesn't tell us how to draw icons: https://codelabs.developers.google.com/codelabs/complications/index.html?index=..%2F..%2Findex#3
I could instead just copy all the drawables to the local wearable module, and bypass the icon type by passing in a string, and from there just draw the appropriate bitmap. But there must be a way to draw from the icon otherwise why have it?
I also couldn't find out from Googling how to convert the icon to a bitmap, but that also seems silly as I had to convert the bitmap to an icon in the first place as the API wants an icon.
Any help appreciated.
Thanks.
Ok so I don't know how I missed this but it's as simple as
Then just do this which you probably already knew:
I was looking here
https://developer.android.com/reference/android/graphics/drawable/Icon.html#loadDrawable(android.content.Context)
and then saw it and wondered why I hadn't tried that.
Edit in reponse to comment: If you want to use a VectorDrawable then adapt as necessary.