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
Related
I want to take a photo with the camera app which is default on the device. After taking it I have my own preview on which the user can input a text and accept the picture or refuse it. This already works fine.
My problem is now that some user has activated the preview option in the default camera app. Is there a parameter for the Intent to deactivate the default setting and send the picture directly to my app without a preview? I don't find a documentation for this case...
I start the camera with the following code
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
this.startActivityForResult(takePictureIntent, MY_CAMERA_REQUEST_CODE);
}
The alternative is to create a own camera in my app. But this is in my opinion a little bit oversized.
Thanks in advance for any help.
There is no possibility to disable the preview programmatically. If something different is needed as the settings of the default camera, an own camera has to be implemented :-(
I am working on an app in which i have to click a pic a pic and save it to a specified folder. I am using android.provider.MediaStore.ACTION_IMAGE_CAPTURE in intent to invoke the camera .I am done with coding and my activity is working fine.But now i have a question in my mind that whether i should stick with this code or i should use the code given here.Need your precious suggestions on this topic.
Thanx in advance.
If you want to just click a picture and save it to a specified folder nothing more then You can use Intent and call ACTION_IMAGE_CAPTURE, it easy to let handle on camera activity do your stuff,
And If your application has some serious deep work with camera when you want to modify preview screen size, and all those things,(For this you have to handle all things like to manage camera, and when to release it, check for don't freeze main UI..) then you have to go with the code you suggested...
Choice is yours.....
I suggest you use the code from your link.
Because most of the stock camera apps don't work as expected with Image Capture. For example the Galaxy S2 and most other Samsung and HTC phones give you the picture bytes back and also save the picture in the standard DCIM Folder on SD-Card, if you want it or not.
public void imageFromCamera() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
Log.d(TAG, "No SDCARD");
} else {
mImageFile = new File(Environment.getExternalStorageDirectory()+File.separator+"MyApp",
"PIC"+System.currentTimeMillis()+".jpg");
mTempImagePath = mImageFile.getAbsolutePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
startActivityForResult(intent, TAKE_PICTURE);
}
}
this what u r searching i am thinking..
I use
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(getSomePath()+"temp.jpg")));
//intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
to get a picture and the saved picture returns as full-size.
But I want to get a limited picture, like 800*640, because on different devices I get different sizes, and I don't need that big picture.
I notice that there is a EXTRA_SIZE_LIMIT in MediaStore , but I can't find how to use it, what parameter should be set?
Answering my own question.
Finally I found that's because different manufacturers customize their Rom, including the Camera app, so the best way is not to call the default camera app, instead we can write a activity use hardware.camera to take picture. There are a lot of examples for this around the Internet too.
Unfortunately EXTRA_SIZE_LIMIT used for video limit in bytes.
I made a program whose major function is use API to take photos and store them in the path I gave.
But things don't come out right on different phones comparing to that when I tested on the emulator or phone with Google's origin ROM.
Theoretically. If I gave a path to the Intent, the photo shouldn't appear in the phone's default gallery, but on MOTO Defy the photos were stored in both my path and default image directory. And on Samsung, my app crashes silently when return from the camera Intent. And only on some phones I can bring up menu by pressing the menu button in the Camera Activity. And even some of them saves photo as the size I set in the Camera Activity's setting menu.
I think this is because the manufacturers customized the ROM on their phones so the Camera Activity acts differently.
Anyone know how to avoid this situation? Or is there any other way to take photos not by the intent "android.media.action.IMAGE_CAPTURE" ?
The following is the code how I take photos.
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(getpath()+"_.jpg")));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
The way that #balban shah offered worked all the same when I tried.
Finally I found that's because different manufacturers customize their Rom, including the Camera app, so the best way is not to call the default camera app, instead we can write a activity use hardware.camera to take picture. There are a lot of examples for this around the Internet too.
try to use this code keep other setting same for photo capture
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(origImageFile));
startActivityForResult(cameraIntent, 0);
I have written an application in android 1.5 to take a snapshot using SurfaceView. The image taken will have pink color fill at center. When we use a default camera application the photos are fine. I know there are some issues in android 1.5, also some hardware issues in some devices, however is there any workaround or settings to overcome this ?
Instead of SurfaceView you can use default camera.
final Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(new File(FILE_PATH)));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 3);
startActivityForResult(intent, CAMERA_CODE);
And in onActivityResult() fetch the image data from your sdcard.
It is working in 1.5 also.