【发布时间】:2013-12-25 15:24:46
【问题描述】:
我一直在尝试关注Android tutorial 分享文件。
我这样设置FileProvider:
在主清单 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 输出?
-
这是完整的 logcat:pastebin.com/xbyMewHc
标签: android filepath illegalargumentexception android-fileprovider