我正在使用文件提供程序将照片保存到给定的目的地。我得到:
java.lang.IllegalArgumentException:尝试打开活动以从相机捕获图像时缺少 android.support.FILE_PROVIDER_PATHS 元数据。
我的 manifest.xml 文件:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/paths" />
</provider>
我的paths.xml 文件:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="content" path="Android/data/com.my_package_name/files/" />
</paths>
和Java代码:
File externalFilesDirectory = this.getExternalFilesDir(null);
File imageFile = File.createTempFile(
imageFileName,
".jpg",
externalFilesDirectory
);
Uri photoURI = FileProvider.getUriForFile(this, "com.example", imageFile);
最后一行给出了例外。我在这里想念什么?我已经按照官方 Android 开发网站的教程(https://developer.android.com/training/camera/photobasics.html)