I have an app that a user will be able to take pictures with. Having the camera is a small, but necessary feature but I want it to only be able to take pictures (no video). Is there a way I can make it startIntentForResult with a pictures-only camera intent? Or perhaps make it only accept images as the result? Making my own custom camera for the app seems a bit overkill, but I will do it if I have to.
Thanks
This code has been working for me for ever
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Uri uri = Uri.fromFile(File.createTempFile("image", ".jpg"));
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(Intent.createChooser(cameraIntent, "Take Picture", 0);
Related
I'm creating a Sign-Up page from my app that has the option to obtain an image from the gallery using this code:
Intent pickImageFileIntent = new Intent(Intent.ACTION_PICK);
pickImageFileIntent.setType("image/*");
String pickTitle = getString(R.string.select_img_gallery);
Intent chooserIntent = Intent.createChooser(pickImageFileIntent, pickTitle);
startActivityForResult(chooserIntent, PICK_IMAGE);
After the user selects the image from the gallery I show that image in an ImageView using Glide, and it works fine. But when I try to use that image's Uri in another activity I get permission denied and the app crashes, so I think the Uri only has permissions for the Activity where ti was obtained. I tried to use ACTION_GET_DOCUMENT instead of ACTION_PICK and it works but the problems is in the Intent chooser it only shows the file explorer instead of the default media gallery and Google Photos, like when I use ACTION_PICK. Is there a way to use the Uri outside the activity while still using ACTION_PICK?
please help
how can i do preselection all for user in a native android gallery ?
here is a code
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);
final Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image");
activity.startActivityForResult(chooserIntent, IMAGE_PICKER_REQUEST);
its working fine, but initial stage 0 files are selected
thanks
There is no means of pre-selecting anything when using ACTION_GET_CONTENT, let alone pre-selecting everything.
Also note that ACTION_GET_CONTENT is not tied to a gallery app, and there is no single "native Android gallery" app across the ~10,000 Android device models.
In my android application, I implemented a feature to pick an image from Gallery. For that earlier I was doing this-
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
pickImageIntent.setType("image/*");
startActivityForResult(pickImageIntent, GALLERY_REQUEST_CODE);
By doing this, a dialog with all available image source application like Dropbox including Native Gallery app were displayed and it asks to choose one. Then I changed to
Intent pickImageIntent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickImageIntent.setType("image/*");
startActivityForResult(pickImageIntent, GALLERY_REQUEST_CODE);
By doing this most of applications were not diplayed but still some like Picasa are diplayed. I want to pick an image from Device's native gallery app only or we can say from either device's internal or external memory not from any third party application.
If any one has solution for this please help me with that.
To pick image from Gallery only
Intent pickImageIntent = new Intent(Intent.ACTION_PICK);
pickImageIntent.setType("image/*");
startActivityForResult(pickImageIntent, GALLERY_REQUEST_CODE);
How to reduce the size of camera picture while saving, using the camera action intent.
I was trying to use MediaStore.EXTRA_SIZE_LIMIT in putExtra of the camera action as below :
Intent captureintent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
captureintent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
captureintent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
captureintent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, 0);
captureintent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, The Value to be Kept);
But this doesn't seem to work.
What is the efficient way to do so?
This is not possible on Android. ACTION_IMAGE_CAPTURE can only be used with MediaStore.EXTRA_OUTPUT, not the other three extras.
See http://developer.android.com/reference/android/provider/MediaStore.html.
I am opening android camera using intent like this :
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
But camera always opens 6mp resolution (i think its devices max camera resolution) i want to open it lower resolution like 2mp. Is there anyway to do this
Thanks for any advice.
Unfortunately there is no way you can do this. Once a different application is lauched the settings of that app can only be changed by the user using the application.
It would be disastrous to allow other apps to change the settings of an app.
So you have two options now -
Build you own camera activity and take pictures in the resolution that you want
Tell the user to take pictures only at the resolution that you specidy, basically ask the user to change the camera resolution to the one you want in the camera application before he takes a picture..
This option is available only for video capturing, using this lines
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // high quality
startActivityForResult()
For our disasapoitment "MediaStore" don`t have parameter for EXTRA_IMAGE_QUALITY