Reputation: 18130
I have a camera intent set up to try to create a file in the root of my device.
File storagePath = new File(Environment.getExternalStorageDirectory()+ "/Football_Fans");
storagePath.mkdirs();
File file = new File(storagePath, "FAN_IMAGE_TEMP");
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, storagePath);
startActivityForResult(cameraIntent,CAMERA_REQUEST_IMAGE);
When I run my application, I don't have any activityOnResult set, but I use fileExplorer to try to see if my file was created. My folder gets created fine, but the photo does not show up. Any idea why?
The documentation states that if an EXTRA_OUTPUT
is set, it will write to that location. So I'm confused why it's not working.
The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.
Upvotes: 0
Views: 1412
Reputation: 12150
use Uri. try this
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(storagePath));
Upvotes: 3
Reputation: 6229
"..will be written to the Uri value of EXTRA_OUTPUT."
You are passing in a File object (storagePath). It expects a Uri so use this:
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(storagePath));
Upvotes: 1