android - 如何在奥利奥的应用程序图标上显示多个通知计数徽章?
问题描述
我收到奥利奥版本的通知。但我需要在应用程序图标上显示计数徽章。我无法显示计数徽章。
获取通知的函数
public void sendOnChannel1(View v){
String title = editTextTitle.getText().toString();
String messagge = editTextMessage.getText().toString();
Notification notification = new NotificationCompat.Builder(this,CHANNEL_1_ID)
.setSmallIcon(R.drawable.ic_one)
.setContentTitle(title)
.setContentText(messagge)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setNumber(3)
.setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)
.build();
notificationManager.notify(1, notification);
}
此功能用于创建通知通道
private void createNotificationChannels() {
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
try{
NotificationChannel channel1=new NotificationChannel(CHANNEL_1_ID, "Channel 1", NotificationManager.IMPORTANCE_HIGH);
channel1.setDescription("This is Channel 1");
channel1.setShowBadge(true);
channel1.canShowBadge();
NotificationManager manager=getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel1);
}
catch (Exception e){
e.printStackTrace();
}
}
}
我想在应用程序图标上显示计数徽章。请帮忙
提前致谢 :)
解决方案
这不取决于你......来自DOC:
设置此通知表示的项目数。可以显示为支持标记的启动器的标记计数。
因此,如果用户在没有徽章支持的情况下使用 Launcher,他将不会得到任何点,更不用说数字......我个人在我的设备上使用(默认)Launcher,它只支持点,根本没有数字
推荐阅读
- c# - 如何从父类继承的子类调用父函数?
- python - ModuleNotFoundError:安装 python-poppler-qt5 时没有名为“sipdistutils”的模块
- mysql - 使用 mysql 8 SHA2 进行 dovecot 密码散列
- javascript - pushstate() 中的 stateobject 应该是什么?
- automation - 多版本应用程序自动化 - TOSCA
- android - 如何更改状态:点击另一个图像视图后激活?
- python - Pandas 计算 - 对于大小为 0 的轴 0,索引 0 超出范围
- reactjs - 材质 ui 使结帐可见
- ios - iOS:未报告扩展程序崩溃
- r - size() 使用 Rcpp 但不是 RcppArmadillo