これはパスを書く際の私の愚かさかもしれませんが、ここに私のコードがあり、構成されたルートを見つけることができません。getUriForFile がエラーの原因です。
@Override
public void onClick(View v) {
if (v.getId() == R.id.main_activity_camera_access_button) {
Log.d(TAG, "clicked");
Toast.makeText(getContext(), R.string.first_activity_toast_opening_camera, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(intent.resolveActivity(getActivity().getPackageManager()) != null) {
mPhotoFile = null;
try {
mPhotoFile = createImageFile();
} catch (IOException ex) {
Log.d(TAG, "exception while creating photo file");
}
if(mPhotoFile != null){
mfileUri = FileProvider.getUriForFile(getContext(), "edu.lclark.imagineyourwall.fileprovider", mPhotoFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mfileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
}
//mfileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
}
}
res の下に xml ディレクトリがあり、そこに my_paths.xml があります。my_paths.xml のコードは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images"
path="Android/data/edu.lclark.imagineyourwall.name/files/Pictures" />
</paths>
また、私のマニフェストは、少なくともプロバイダー部分は次のようになります。
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="edu.lclark.imagineyourwall.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/my_paths"></meta-data>
</provider>