java - 我可以更改通知渠道的重要性吗?
问题描述
我需要使用两种具有不同通知渠道重要性的不同通知——一种使用 NotificationManager.IMPORTANCE_LOW,另一种使用 NotificationManager.IMPORTANCE_MIN。我不能使用两个不同的通知通道,因为两者都需要具有相同的通道名称,如果那样,通知设置将被复制。我试着用
notificationManager
.getNotificationChannel(NotificationUtils.NOTIFICATION_CHANNEL_ID)
.setImportance(NotificationManager.IMPORTANCE_LOW);
但它并没有改变通知渠道的重要性。然后我尝试从 NotificationManager 中删除通知通道并创建新通道,就在构建通知之前:
notificationManager.deleteNotificationChannel(NotificationUtils.NOTIFICATION_CHANNEL_ID);
notificationManager.createNotificationChannel(new NotificationChannel(
NotificationUtils.NOTIFICATION_CHANNEL_ID,
context.getString(R.string.app_name),
NotificationManager.IMPORTANCE_LOW));
但它也不会改变重要性。