【发布时间】:2017-09-01 12:41:01
【问题描述】:
我正在使用带有 Android Oreo SDK 的 Google Nexus 5x 进行测试。我在主屏幕的应用程序图标中找不到通知徽章,即使我从应用程序收到通知并且应用程序快捷方式未显示数字。以下是 sn-p:
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);
}
【问题讨论】:
标签: android badge shortcut android-8.0-oreo