我使用谷歌Nexus 5x与Android Oreo SDK进行测试.我无法在主屏幕中找到应用程序中的通知徽标图标,即使我从应用程序获得通知并且应用程序快捷方式未显示数字.以下是片段:
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);
}
Run Code Online (Sandbox Code Playgroud)