【发布时间】:2017-11-02 03:00:14
【问题描述】:
我知道这个问题之前已经回答过了,但我仍然无法解决。我已经将 mp3 放入原始文件夹,并且我知道到它的路径是有效的,因为我使用 Ringtone 和 MediaPlayer 类进行了测试。通知创建得很好,但没有声音(而且我的设备上的音量最大)。这是我的代码
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setLargeIcon(icon)
.setSmallIcon(R.drawable.logo)
.setContentTitle(notification.getTitle())
.setContentText(notification.getBody())
.setSound(sound)
.setPriority(Notification.PRIORITY_HIGH);
mBuilder.setContentIntent(contentIntent);
Notification mNotification = mBuilder.build();
mNotification.sound = sound;
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mNotification);
【问题讨论】:
-
您能否正确格式化您的代码?就像它很难阅读一样。你可以在这里找到一些帮助:stackoverflow.com/editing-help