【发布时间】:2015-07-10 15:58:13
【问题描述】:
我正在尝试使用FileProvider 播放来自私有路径的视频。面对
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/XXXXX(Package)/files/Videos/final.mp4
代码:
<paths>
<files-path path="my_docs" name="Videos/" />
</paths>
Java 代码:
File imagePath = new File(getFilesDir(), "Videos");
File newFile = new File(imagePath, "final.mp4");
Log.d(TAG, "-------------newFile:"+newFile.exists());//True here
//Exception in below line
Uri contentUri = FileProvider.getUriForFile(this,"com.wow.fileprovider", newFile);
清单.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.wow.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
这有什么线索吗?
谢谢 尼兹
【问题讨论】:
-
在实现 Fileprovider 时,我在 @xml/file_paths 中收到“属性缺少 Android 命名空间前缀”。后来不知何故,我把名称和路径放错了位置,最后遇到了这个问题。跨度>
标签: android android-fileprovider