【发布时间】:2017-08-02 20:04:07
【问题描述】:
sound = Uri.parse("file://" + audioFilePath.getAbsolutePath());
/*sound = Uri.fromFile(audioFilePath);*/
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this);
mBuilder
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(title)
.setContentText(description)
.setContentIntent(resultPendingIntent)
.setSound(sound);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mBuilder.setPriority(Notification.PRIORITY_HIGH);
}
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
声音文件存在于本地存储中。通知工作正常,但声音不播放。我尝试了两种从文件路径解析 Uri 的方法。
【问题讨论】:
标签: android notifications