I'm taking photos via Intent in my app, photos are saved into my specified folder on SD, but also they are saved into DCIM default camera folder. I do NOT want them twice. How can I disable saving of captured photos into this defalut camera directory?
Thank you in advance.
Here is what I'm using
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
Related
When user press on button open sd card and can select any document in like gallery with Android SDK.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
startActivityForResult(intent, IMAGE_CAPTURE);
Use Intent.ACTION_GET_CONTENT. On modern systems you can use Intent.ACTION_OPEN_DOCUMENT too.
In my app, I am calling camera that should capture picture and store it on given path:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
public static String pic_path =Environment.getExternalStorageDirectory().toString()+name;
File file = new File(pic_path);
Uri outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, REQUEST_CAMERA);
It works fine on devices that have SD card or any kind of External Storage. But it does not work on others (it crashes). So, what is alternative? How would I make this code work for devices without SD card/External Storage?
I'm using camera in my android app to click pictures and saving them in my app directory, using this:
File mediaStorageDir = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath());
The image gets saved successfully to my app directory in internal storage.
But it also gets saved to my sdcard/dcim directory (which is my default camera pics storage location).
I tried capturing this location from sdcard, so that I can delete after capture, but unable to do so.
I don't want my app specific pics to be visible in gallery.
Try to do like this:
String IMAGE_DIRECTORY_NAME = "FolderName";
File imagesFolder = new File(Environment.getExternalStorageDirectory(),
IMAGE_DIRECTORY_NAME);
imagesFolder.mkdirs();
File image = new File(imagesFolder, "image.jpg");
fileUri = Uri.fromFile(image);
For capturing the picture form camera:
imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(imageIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
This will save your image to the gallery folder specified in IMAGE_DIRECTORY_NAME, and not in default directory for Camera.
Now you will be able to manage the directory of your images and delete whatever image you want.
I'm trying to save the image captured via android camera in a custom location. My code looks like this:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File f = File(android.os.Environment.getExternalStorageDirectory(), "test.jpg");
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, SUB_ACTIVITY_CAMERA_PREVIEW);
The image is being saved to the desired location but it is also being saved to the default camera folder which is causing it to be displayed in the gallery. Any suggestions?
Include an empty file named .nomedia in your external files directory (note the dot prefix in the filename). This will prevent Android's media scanner from reading your media files and including them in apps like Gallery or Music.
File is present in sdcard/image.jpg
I would like to create my own application (activity).
On a button press, the image stored in the sdcard needs to be displayed using the built-in image viewer.
On pressing the back button from the Image viewer, it should go back to my running application.
Need some help.
you can create an Intent with proper uri and mimetype for this.Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///sdcard/image.jpg"), "image/jpeg");
startActivity(i);
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
This code use for display all images from your SD card