FileProvider 错误“无法找到包含/data/data/sawbodeployer.entm.illinois.edu 的配置根目录..." [英] FileProvider error "Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu ..."
问题描述
我通过 android 下载管理器下载视频并想分享这个视频,我按照 Manifas
I download video by android download manager and want to share this video, I follow through Manifas
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="my.domain"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/paths" />
</provider>
并在文件 path.xml 中添加:
and in file path.xml add this:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="video_folder" path="files/"/>
</paths>
并使用此提供程序:
File file = new File(getActivity().getFilesDir() , videoPath);
Uri uri = FileProvider.getUriForFile(getContext(), "my.domain", file);
Intent intent = ShareCompat.IntentBuilder.from(getActivity())
.setType("video/3gp")
.setStream(uri)
.setChooserTitle("Choose bar")
.createChooserIntent()
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
但我收到错误:
java.lang.IllegalArgumentException:无法找到包含/data/data/sawbodeployer.entm.illinois.edu/files/AKA1_Fante_Ghana_HandWashing_Final.3gp 的配置根目录
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu/files/AKA1_Fante_Ghana_HandWashing_Final.3gp
问题出在哪里?
推荐答案
替换:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="video_folder" path="files/"/>
<files-path name="name" path="path" />
</paths>
与:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="video_folder" />
</paths>
path
当根目录下有一些特定的子目录要提供服务时使用.您的文件直接在 getFilesDir()
中,因此您不能使用 path
.
path
is used when there is some specific subdirectory under the root that you want to serve from. Your file is directly in getFilesDir()
, and so you cannot use path
.
这篇关于FileProvider 错误“无法找到包含/data/data/sawbodeployer.entm.illinois.edu 的配置根目录..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!