Search code examples
androidwear-osandroid-wear-notification

Wearable Notification that is updated frequently causes flicker


On a wearable my app displays a rest timer as shown in the picture. It simply counts down and is updated each second.

My problem is that since it is updated each second, it creates a flickering effect.

  • The icon is hidden for just long enough for you to be able to notice it.

  • The actions related to the card (accessible through swiping) also flicker similarly, and at times display the totally wrong information such as another items icon and text. The actions are same for the whole duration of the rest timer.

Ive tried updating it each 5 seconds or so but it unfortunately ruins the whole thing and makes it very unintuitive. Its my best option at the moment though.

Is it possible to update the notification each second without causing the flicker?

Wearable app


Solution

  • If you want to show a notification with a timer, either counting up or down, that's a built-in feature for that. Here's some code I wrote that puts it all together for Android Wear:

    https://github.com/danwallach/XStopwatch/blob/master/wear/src/main/java/org/dwallach/xstopwatch/NotificationHelper.java

    Notably, you'll want your notification builder to do something like this: builder.addAction(android.R.drawable.ic_media_pause, "", clickPendingIntent) .setWhen(eventTime) .setUsesChronometer(true) .setShowWhen(true);