Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ACTION_IMAGE_CAPTURE with EXTRA_OUTPUT in internal memory

When I'm taking a photo from a camera if I'm calling

File file = new File(getFilesDir().getAbsolutePath() + "/myImage.jpg");
Uri outputFileUri = Uri.fromFile(file);

cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

OK button on camera app is not functioning, simply does nothing (actually won't save it to internal memory I provided I guess and therefore the app itself does nothing).

If I however call

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/myImage.jpg");
Uri outputFileUri = Uri.fromFile(file);

cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

everything is fine and photo is stored on SDCard.

My question is, is there a way to store capture photo in full-resolution without SDCard?

like image 533
svenkapudija Avatar asked Dec 07 '22 11:12

svenkapudija


2 Answers

The native camera app cannot save the image in your app's private internal directories as those are only available to your particular app.

Instead you can create a custom camera activity to save images to your internal directories or you need to use the stock camera app with external storage.

Note: if you plan on creating a custom camera activity make sure you target at least 2.3 and up. Anything below that mark is very difficult to work with.

like image 113
BoredAndroidDeveloper Avatar answered May 01 '23 09:05

BoredAndroidDeveloper


The Camera activity will not be able to save the file into your activity's private files directory, that's why it fails quietly. You can move the image from the external storage into your files dir in onActivityResult.

like image 28
katzoft Avatar answered May 01 '23 09:05

katzoft