我一直在試圖關注共享文件上的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