我看到了documentation:
public Uri sound
Added in API level 1
The sound to play.
To play the default notification sound, see defaults.
但如何禁用声音播放?发送Uri == null
?
答案 0 :(得分:2)
如果您不使用NotificationBuilder调用setSound(uri),则无法播放声音。 例如。 以下内容将播放默认的通知声音:
Uri alarmSound = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("title")
.setSound(alarmSound);
只需删除“.setSound(alarmSound)”即可播放声音,如:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("title");
希望我的问题正确(?)