-
Before
Notification.Buildercame into existence the way to update a notification that was already in the notification tray was to callsetLatestEventInfo()and then send the notification back through theNotificationManager.notify()call with an ID that matches the firstnotify()call you made. -
Now
setLatestEventInfo()is deprecated with the message:Use Notification.Builderinstead. But I cannot find any documentation about how to properly update a notification usingNotification.Builder. -
Are you just suppose to recreate a new
Notificationinstance every time you need to update the notification? Then simply pass that toNotificationManager.notify()with the ID you used before? -
It seems to work but I wanted to see if anyone had any official verification that this is the new “way to do this”?
There real reason I am asking this is because in Android 4.1.1 Jelly Bean, the notification now flashes everytime notify() is called. When updating a progress bar with setProgress() this looks really bad and makes it hard to tap on the notification. This was not the case in 4.1 or previous versions. So I want to make sure I am doing this correctly before I file a bug.
I resolved this issue by calling
setWhen(0)on my Notification.Builder. It seems Android’s default value for this argument doesn’t suit updating bits of the notification view without the entire notification fading out / in.Update:
As WolframRittmeyer stated, using
when=0is not an elegant way. I formed a solution like following: