Unread notification count complication in Android Wear 2

1k Views Asked by At

I'm developing a series of Android Wear 2 watch faces and apparently I've found a problem I cannot solve.

In the images you can see two simple watch faces from Google (I'm sorry I cannot embed images, yet). The first one is from the Google Developer Codelabs example project.

Google Developer Codelabs watch face

The second one is installed by default in AW2 and it's called "Elements analog" (but there is also an "Elements Digital", quite similar). I've disabled all the other complications except the left one.

Elements analog watch face

Both watch faces are showing information from the same complication data provider, the system unread notification count (in the complication helper, select General -> Unread notification count).

However, as you can see, the same information is displayed in two very different ways.

My problem is, I cannot undestand how this is possible. The Unread notification count complication is of type TYPE_ICON.

As per documentation, the only information present in the ComplicationData associated with the complications of type TYPE_ICON, is an icon, retrievable by calling complicationData.getIcon(). And, infact, the icon is there an it is an image of the actual number of unread notifications. The image of a number in a circle (as you see in the first watch face). There is no bell icon (second watch face) and there is no separated unread count value in another variable. Nothing.

I thought I could avoid using the Complications Drawable method to draw the complication and do it my own way, but, as I said, the only thing I know of the complication, when it is created or updated, is that it is of TYPE_ICON type. Nothing else. No provider name, no value. Just a number icon.

What am I missing? How can i draw the complication in a way similar to the one in the second image?

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

I managed to draw the unread count complication as in the second image (the Elements analog watch face), as I wanted.

It was a matter of the order in which the complication supported types were declared. In the Codelabs watch face code (the first above image), this was the declaration order for a single complication:

TYPE_RANGED_VALUE,
TYPE_ICON,
TYPE_SHORT_TEXT,
TYPE_SMALL_IMAGE

As you can see, the TYPE_ICON type comes before the TYPE_SHORT_TEXT one. This changes the way in which the data provider, which for the unread notification count is a system one, assembles the complication data.

By declaring the complication supported type in this order:

TYPE_RANGED_VALUE,
TYPE_SHORT_TEXT,
TYPE_SMALL_IMAGE,
TYPE_ICON

the complication data comes in the form of a TYPE_SHORT_TEXT, with the bell icon and the unread count value, as desired.

The documentation is quite unclear about this, I think. All I have found (here: https://developer.android.com/training/wearables/watch-faces/complications.html) is: "The types should be listed in order of preference, usually with types offering more information, such as ranged value, given higher preference"

Hope this helps.