我有一个我构建的自定义notification
,每次弹出它都会发送一个notification sound
。我希望这是silent
,不要发出任何声音。我已经尝试了下面的所有方法,但似乎都不起作用。所有的东西似乎都被弃用了,setPriority()
不是一个选项。正在寻找如何让notification
声音保持静音的解决方案,有什么帮助吗?我的代码如下。
尝试使用以下所有方法的组合:
status.sound = null;
status.vibrate = null;
status.defaults &= ~DEFAULT_SOUND;
status.defaults &= ~DEFAULT_VIBRATE;
status.vibrate = new long[] { -1 };
status.priority = -2
我的代码
Notification status = new NotificationCompat.Builder(this, CHANNEL_1_ID).build();
status.contentView = views;
status.bigContentView = bigViews;
status.flags = Notification.FLAG_ONGOING_EVENT;
status.icon = R.drawable.ic_music_note;
status.contentIntent = pendingIntent;
status.priority = -2;
startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, status);
https://stackoverflow.com/questions/50670902
复制相似问题