问题
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>
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>
and use this provider:
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);
but I get error :
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/sawbodeployer.entm.illinois.edu/files/AKA1_Fante_Ghana_HandWashing_Final.3gp
Where is its problem?
回答1:
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
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
.
来源:https://stackoverflow.com/questions/44247796/fileprovider-error-failed-to-find-configured-root-that-contains-data-data-sawb