我一直在试图关注共享文件上的Android tutorial。 我成立了FileProvider
这样的:IllegalArgumentException:未能在FileProvider.getUriForFile上找到包含xxx的配置根
在主清单XML:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.mysecondapp.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
的RES/XML/filpaths.xml文件:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="myexternalimages" path="SpCars_album/" />
</paths>
而在我的代码,我想如下:
File requestFile = new File(mImageFilenames[position]);
try {
fileUri = FileProvider.getUriForFile(
SeventhActivity.this,
"com.example.mysecondapp.fileprovider",
requestFile);
} catch (IllegalArgumentException e) {
Log.e("File Selector",
"The selected file can't be shared: " +
mImageFilenames[position]);
}
requestFile被实例化一个适当的文件的工作路径。 该文件的路径始于getExternalFilesDir(Environment.DIRECTORY_PICTURES)
返回的路径。 我只是不明白是什么引起了错误,因为一切似乎都适合。 在此先感谢。
您能否提供完整的logcat输出? – bbuecherl
这是完整的logcat:http://pastebin.com/xbyMewHc – AndroidNewbie