[英]how to disable sound on push notification?
I saw the documentation : 我看到了文档 :
public Uri sound
Added in API level 1
The sound to play.
To play the default notification sound, see defaults.
but how do I disable sound playing? 但是如何禁用声音播放? sending
Uri == null
? 发送
Uri == null
?
If you don't call setSound(uri) with NotificationBuilder, the sound won't play. 如果不使用NotificationBuilder调用setSound(uri),则无法播放声音。 Eg.
例如。 The following would play the default sound for notification:
以下内容将播放通知的默认声音:
Uri alarmSound = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("title")
.setSound(alarmSound);
Just remove ".setSound(alarmSound)" and it won't play the sound, like: 只需删除“.setSound(alarmSound)”即可播放声音,如:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("title");
Hope i got the question right(?) 希望我的问题正确(?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.