ファイルプロバイダを使用して、指定された宛先に写真を保存しています。 私が取得:Androidファイルプロバイダ不正な引数例外
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)からチュートリアルに従った
チュートリアルのリンクを追加できますか? –
うん、今すぐそれをした –
'com.example'は' 'com.example" 'でなければなりません。それで解決しますか? –