Im testing with Google Nexus 5x with Android Oreo SDK.I cant find Notification Badges in App icon in Homescreen,even i got notification from App And app shortcut is not showing Number.The following is snippet:
final NotificationManager mNotific=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name="Ragav";
String desc="this is notific";
int imp=NotificationManager.IMPORTANCE_HIGH;
final String ChannelID="my_channel_01";
NotificationChannel mChannel=new NotificationChannel(ChannelID,name,imp);
mChannel.setDescription(desc);
mChannel.setLightColor(Color.CYAN);
mChannel.canShowBadge();
mChannel.setShowBadge(true);
mNotific.createNotificationChannel(mChannel);
final int ncode=1;
String Body="This is testing notific";
final Notification n= new Notification.Builder(getApplicationContext(),ChannelID)
.setContentTitle(getPackageName())
.setContentText(Body)
.setNumber(5)
.setBadgeIconType(R.mipmap.ic_launcher_round)
.setSmallIcon(R.mipmap.ic_launcher_round)
.setAutoCancel(true).build();
for(int i=0;i<25;i++) {
Thread.sleep(1000);
mNotific.notify(ncode, n);
}
You cannot customize the appearance of notification badges (dots) that appear on your app's launcher icon. You can however customize some elements of the long-press menu when you long-press your app's launcher icon, the .setNumber(5)
that you tried will show up there for example.
Refer here for more insight: Notification Badges and Adjusting Notification Badges.
Referring to .setBadgeIconType(R.mipmap.ic_launcher_round)
, I would suggest you read this.
** EDIT ** (question misunderstood)
I have tested your code (without the for
loop, calling mNotific.notify(ncode, n);
only once) on a Nexus 5X emulator and it works 100% with notification dots being shown. This is not a code related issue.
The Nexus 5X physical device's native launcher app (Google Now) does not support notification dots even though you can turn notification dots "on" in Oreo Settings on the device. Refer to this and this link. To enable notification dots on a Nexus 5X physical device you'll have to install a custom Pixel Launcher app such as this Rootless Pixel Launcher.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With