Reputation: 1151
I have no code to handle the notification badges and on Android developer webpage says: "... and there's nothing your app needs to do..."
https://developer.android.com/training/notify-user/badges
The issue is that after the badge appears it doesn't disappear when I go directly to the App. It looks like I need some more code in my App. Any idea about what is happening?
All this is in Android Oreo.
Upvotes: 2
Views: 3308
Reputation: 4956
You can also choose not to show the badge at all when you build a notification channel:
/**
* Sets whether notifications posted to this channel can appear as application icon badges
* in a Launcher.
*
* Only modifiable before the channel is submitted to
* {@link NotificationManager#createNotificationChannel(NotificationChannel)}.
*
* @param showBadge true if badges should be allowed to be shown.
*/
public void setShowBadge(boolean showBadge) {
this.mShowBadge = showBadge;
}
Upvotes: 0
Reputation: 23665
The badge on an app's icon is shown as long as a notification of that app is shown .
You can either set autoCancel to true for your notification, or you prgrammatically cancel any notification of your app via NotificationManager, when the app becomes active, i.e. in onStart or onResume of the Activities your notification leads to.
Upvotes: 2