1

I have an Image-Picker in my app.

  • When I choose an image from Google Photos I have to save its URI
  • Then I need to to show this image into an ImageView using this URI.
  • I try to request Google Photo permission but it has no result.

public static final String GOOGLE_PHOTOS_PERMISSION="com.google.android.apps.photos.permission.GOOGLE_PHOTOS";

Is it possible to get an image by URI from Google Photos?

Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
Serhii K.
  • 499
  • 1
  • 7
  • 16

2 Answers2

0

Convert the Uri into Bitmap using this snippet:

private Bitmap getBitmapFromUri(Uri uri) throws IOException {
    ParcelFileDescriptor parcelFileDescriptor = getContentResolver().openFileDescriptor(uri, "r");
    FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
    Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
    parcelFileDescriptor.close();
    return image;
}

now set this Bitmap to ImageView.

user2340612
  • 9,145
  • 4
  • 40
  • 63
0

You Can Use Picasso Library.

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);

Use the Gradle File

compile 'com.squareup.picasso:picasso:2.5.2'

Check Picasso Library Documentation

Tomin B Azhakathu
  • 2,648
  • 1
  • 18
  • 27