Skip to content Skip to sidebar Skip to footer

How To Select An Image From Gallery Or To Capture A Photo And Then To Display It In Another Activity Full Quality

I have two image buttons,for camera and gallery . If you select 'camera' you can capture a photo from camera and then that photo has to be displayed in another activity in image vi

Solution 1:

There are a few problems with your code, including:

  • getRealPathFromURI() is unreliable in general and unnecessary in this case. Pass the Uri itself to ShowPhotoActivity.

  • ShowPhotoActivity is loading the image on the main application thread. Do not do this. Please use one of many image loading libraries available for Android, as they can load your image asychronously using the Uri. Personally, I use Picasso.

  • You are assuming that you get a Uri back from ACTION_IMAGE_CAPTURE. That is not how ACTION_IMAGE_CAPTURE works.

Instead, replace:

UrireturnUri= data.getData();
    BitmapbitmapImage=    MediaStore.Images.Media.getBitmap(MainActivity.this.getContentResolver(), returnUri);

with:

BitmapbitmapImage= (Bitmap)data.getExtra("data");

Post a Comment for "How To Select An Image From Gallery Or To Capture A Photo And Then To Display It In Another Activity Full Quality"