Search code examples
androidonactivityresult

how to get full size image on camera Intent


I want to get Full size image from camera intent.I have tried bellow code but i getting image size very small.following is my code

Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent , PICK_IMAGE_REQUEST2);

onActivityResult code

    if(requestCode == PICK_IMAGE_REQUEST2)
    {
        //filePath = data.getData();
        bitmap = (Bitmap) data.getExtras().get("data");
        iv_upload.setImageBitmap(bitmap);
        check=true;

        // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
        filePath = getImageUri(getApplicationContext(), bitmap);
    }

Solution

  • By doing this you get the thumb preview as mentioned here

     data.getExtras().get("data");
    

    If you want the full size, you need to create a collision-resistant file name and invoke your intent like this

    Uri photoURI = FileProvider.getUriForFile(this,
                                              "com.example.android.fileprovider",
                                              photoFile);
    
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
    
    startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
    

    Here's the full example