Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camera intent/Activity - avoid saving to gallery

I am using the Camera Activity to capture the picture. I call it with the MediaStore.EXTRA_OUTPUT extra parameter. The image is correctly saved to provided path, put it is saved also to the gallery folder, so I can view the image in "Gallery" application - can I avoid this?

...
File file = new File(Environment.getExternalStorageDirectory(), "Test.jpg" );
iImageOutputUri = Uri.fromFile( file );

// Start camera intent to capture image
Intent intent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, iImageOutputUri );
startActivityForResult( intent, CAPTURE_IMAGE );
...

Thanks

like image 264
STeN Avatar asked Mar 07 '11 15:03

STeN


1 Answers

Just replace your code

File file = new File(Environment.getExternalStorageDirectory(), "Test.jpg" );

with following code

File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "Test.jpg");

Description of getExternalFilesDir() : Returns the absolute path to the directory on the primary external filesystem (that is somewhere on Environment.getExternalStorageDirectory()) where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media.

like image 152
Shailendra Patil Avatar answered Sep 28 '22 18:09

Shailendra Patil