我正在使用文件提供程序将照片保存到指定的目标位置。 我得到了以下错误信息:
java.lang.IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data while trying to open activity to capture image from camera.
我的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)。
com.example
应该翻译为"com.example"
。这样可以解决问题吗? - Imran Ali