I created a project that allow user to take a picture and view it. I have no face any issue while taking, view, save and retrieve the photo. But my problem is the image that camera took is in bad quality, I don't know how to set the quality of the camera Intent
. Here is my code looks like.
....
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
....
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap userPhoto = (Bitmap) data.getExtras().get("data");
iv_user.setImageBitmap(userPhoto);
}
}
Here is a screenshot of while camera is on.
And here is in preview camera mode after the image is captured.
If we compare these two photos, we can see the image in preview mode is blur.
Im actually not sure why it's like that but it's same here after every method tried, so I suggest the solution that you make use of a very simple library like below, good things is your picture quality remains intact.
simple add to your gradle file:
The Android Camera application encodes the photo in the return Intent delivered to onActivityResult() as a small Bitmap (we call it thumbnail) in the extras, under the key "data".
If you want to retrive full size image your app first need to store image to external storage and then read it back. You can access full code at
https://developer.android.com/training/camera/photobasics