0
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。如何從本地文件播放通知聲音