我通过 Android 下载管理器下载视频并想分享此视频,我通过 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中添加以下内容:
<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 的配置根目录
它的问题出在哪里呢?
Replace:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="video_folder" path="files/"/>
<files-path name="name" path="path" />
</paths>
with:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="video_folder" />
</paths>
path
当您想要从根目录下存在某些特定子目录时使用。你的文件直接在getFilesDir()
,所以你不能使用path
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)