【发布时间】:2019-08-24 12:42:18
【问题描述】:
我需要在不播放通知声音的情况下显示通知 使用通知生成器。
我尝试过使用
set sound(null);
我也尝试过使用自定义声音
这是我的代码:
public NotificationCompat.Builder getChannelNotification() {
getData();
return new NotificationCompat.Builder(getApplicationContext(), channelID)
.setContentTitle(time)
.setContentText(text)
.setSmallIcon(R.drawable.ic_android)
.setDefaults(0)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setSound(null);
}
【问题讨论】:
-
您尝试关闭哪个 android 版本
-
@AnasMehar,它是一个多版本的应用程序
-
@gaspar 你试试这个 setDefaults(Notification.DEFAULT_ALL) 代替 .setDefaults(0)
-
@Mohsinkazi,是的,它还在播放声音
-
@gaspar 您正在测试哪个版本