frankish
frankish

Reputation: 6846

What can be the reason behind the failure of setShowBadge(false)?

I am posting a notification for a background task and bring it to foreground with startForeground with a visible ongoing notification. When it completes, I replace it with a cancellable notification using the same notification id and the same channel I created with setShowBadge(false).

The scenario works correctly: It does not show badge for the ongoing task and it is successfully replaced with the non-ongoing version. Except, setShowBadge(false) does not work when I use it for the cancellable notification.

I checked the official sample and many examples and I also checked my code, I could not find any problems. So, there has to be an exceptional situation here. What can be the problem? What am I possibly missing here?

Upvotes: 4

Views: 2032

Answers (1)

Zohaib Amir
Zohaib Amir

Reputation: 3562

It depends on default launcher in use. Stock launcher will work as expected but some launchers have their own implementation of Notification badges and they've been using it since way before badges were supported officially. For those launchers, this flag won't work.

Even if the launchers use notification badges from channels, they might not care about this flag (like in your case). I would say try calling setNumber(0) and hope that it works.

 mNotificationBuilder.setNumber(0)

Upvotes: 2

Related Questions