gpt4 book ai didi

java - 如何在不播放任何声音的情况下显示通知

转载 作者:行者123 更新时间:2023-12-02 01:19:09 25 4
gpt4 key购买 nike

我需要显示通知而不播放通知声音使用通知生成器。

我尝试使用

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);

}

最佳答案

删除 builder.setDefaults(0); 行。它不会播放声音,但如果愿意,您可能需要启用所有其他通知默认值

关于java - 如何在不播放任何声音的情况下显示通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57638052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com