I have an application that allows the user to take a picture with the native camera of the phone, I don't want to implement all the functionality of a camera (I don't want to loose the autofocus, flash or some other properties that the native camera might have) so I make this call:
File folder = new File(Environment.getExternalStorageDirectory(),"folder");
folder.mkdirs();
File nomedia = new File(folder,".nomedia");
try{
nomedia.createNewFile();
}catch (IOException e){
e.printStackTrace();
Log.e("error", e.getMessage());
}
File file = new File(folder,"image.jpeg");
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
imageUri = Uri.fromFile(file);
if(imageUri != null){
Log.i(TAG, "imageUri: " + imageUri.getPath());
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
}
Then in a button I have the execution of the intent:
startActivityForResult(imageIntent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
This works perfectly, it opens the camera, I receive the callback when I take the picture and if I look to the folder with the file explorer of the phone I can see the picture and also the ".nomedia" file that I created.
The thing is that I don't want the camera to store this image in the gallery of the phone, because, somehow this is "magically" ;) added to the Gallery of Android and I thought with adding the ".nomedia" file and creating the picture in a separate folder the Gallery won't scan it. The idea is that the pictures are only for internal use of the app.
Is there anyway of avoiding this? I really searched and try many different ways, but I cannot solve it.
I hope I was clear with the explanation.
Thanks in advance!