历史记录:我从服务器下载铃声,如果将SD卡挂载,我将该文件保存到SD卡路径,如mnt/sdcard/..my__name/abc.mp3,使用context.getFilesDir() like,data/data/my.pace.name/abc.mp3保存到内存中。
问题:我在Notification中启动了通知,Notification正在正常工作,但是当我从内部内存设置通知声音URI时,它不会播放声音。
在外部存储,工作良好,声音播放
ringtoneUri = Uri.parse("file:///mnt/sdcard/.my_folder_name/abc.mp3");
notification.sound = ringtoneUri;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
notificationManager.notify(1, notification);如果是内部存储,不播放声音播放我检查了文件,它存在于那里
ringtoneUri = Uri.parse(context.getFilesDir().getPath()+"/abc.mp3");// data/data/my.package.name/files/abc.mp3
notification.sound = ringtoneUri;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
notificationManager.notify(1, notification);我做错什么了吗?
致以敬意,
发布于 2013-09-18 06:35:57
问题是,通知不支持内部存储。您需要向该音频文件添加公共权限。
File file = new File(context.getFilesDir().getPath()+"/abc.mp3");
file.setReadable(true, false);
ringtoneUri = Uri.parse(context.getFilesDir().getPath()+"/abc.mp3");
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
notificationManager.notify(1, notification);..。
谢谢
萨利克
发布于 2013-09-11 06:09:13
我会检查权限。每个应用程序都是用户。是否所有用户都有权读取文件(可能还有封闭的文件夹)?
https://stackoverflow.com/questions/18733703
复制相似问题