【发布时间】:2018-11-28 05:43:50
【问题描述】:
通知通道的正式声音和振动是
"只能在频道提交前修改
NotificationManager.createNotificationChannel(NotificationChannel)。”
但我现在看到,当转到 Whatsapp 设置并更改声音或振动时,这些更改会出现在相应频道(私人或群组)的设置中。
我该怎么做? (我使用的是安卓 8.1)
【问题讨论】:
标签: android
通知通道的正式声音和振动是
"只能在频道提交前修改
NotificationManager.createNotificationChannel(NotificationChannel)。”
但我现在看到,当转到 Whatsapp 设置并更改声音或振动时,这些更改会出现在相应频道(私人或群组)的设置中。
我该怎么做? (我使用的是安卓 8.1)
【问题讨论】:
标签: android
Whatsapp 不会编辑频道,只要您进行任何更改,他们就会删除频道并创建一个具有相同名称(具有不同 ID)的新频道。我现在发现,每次您进行更改时,“已删除类别”的数量都会增加。
【讨论】:
您可以通过在 notificationChannel
中添加声音和振动来做到这一点例如:
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
String notifyID = "1003";
String CHANNEL_ID = "my_channel_01";// The id of the channel.
NotificationChannel notificationChannel = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_HIGH;
notificationChannel = new NotificationChannel(notifyID, CHANNEL_ID, importance);
notificationChannel.enableLights(true);
notificationChannel.setSound(defaultSoundUri, null);
notificationChannel.setLightColor(Color.RED);
notificationChannel.enableVibration(true);
notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
}
【讨论】: