Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download image from new Google+ (plus) Photos Application

Recently Google added the Photos app for Google+ (plus) and it shows up when you launch an Intent to choose an image. However, if I select an image from Google+ Photos and try to use it in my application none of my current logic is able to return a usable URI or URL to actually get an image that I can download and manipulate. I'm currently using the "common" methods to try to manipulate the URI that can be found here on Stack Overflow and elsewhere. I can provide code if needed, but at this point I think it's kind of irrelevant since it works well for everything else except this new app. Any ideas on how to get a usable image?

The URI looks something like the following:

content://com.google.android.apps.photos.content/0/https%3A%2F%2Flh5.googleusercontent.com%<a bunch of letters and numbers here> 

The MediaColumns.DATA info always returns null and the MediaColumns.DISPLAY_NAME always returns image.jpg no matter what I select from the Google Photos app. If I try to paste everything from https to the end in my browser, nothing comes up. Not sure how to get usable info from this.

like image 988
Jason Avatar asked Nov 06 '13 07:11

Jason


People also ask

How do I download photos from Google Plus?

You can download the photos from a single album: Click on the album to open it opening the album. Click the 3 dot menu icon at top right. Select Download album.

Why can't I download images from Google app?

Check Browser Permissions The browser or the app that you are using to download images from Google search should have the necessary storage permission. If the browser doesn't have the permission, you won't be able to save the images.

How do I download pictures from Google after update?

Method 1 of 2: The image will open in a new tab. You can search for images at https://images.google.com or in the Google app. Tap and hold the image until a menu appears. Tap Download Image on the menu.

How do I move photos from Google Photos to computer?

If you're using a Windows computer, here's how you download your pics from Google Photos: Go to photos.google.com in your browser. Click the checkmark in the top left to select your pics. In the top right, click the three dots and hit Download.


2 Answers

When receiving the data intent, you should use the contentResolver to get the photos. Here's what you should do:

String url = intent.getData().toString(); Bitmap bitmap = null; InputStream is = null; if (url.startsWith("content://com.google.android.apps.photos.content")){        is = getContentResolver().openInputStream(Uri.parse(url));        bitmap = BitmapFactory.decodeStream(is); } 
like image 143
HatemTmi Avatar answered Oct 14 '22 08:10

HatemTmi


I did faced issues selecting images from new Google Photos app. I was able to resolve it by below code.

It works for me, basically what i did is i am checking if there is any authority is there or not in content URI. If it is there i am writing to temporary file and returning path of that temporary image. You can skip compression part while writing to temporary image

public static String getImageUrlWithAuthority(Context context, Uri uri) {     InputStream is = null;     if (uri.getAuthority() != null) {         try {             is = context.getContentResolver().openInputStream(uri);             Bitmap bmp = BitmapFactory.decodeStream(is);             return writeToTempImageAndGetPathUri(context, bmp).toString();         } catch (FileNotFoundException e) {             e.printStackTrace();         }finally {             try {                 is.close();             } catch (IOException e) {                 e.printStackTrace();             }         }     }     return null; }  public static Uri writeToTempImageAndGetPathUri(Context inContext, Bitmap inImage) {     ByteArrayOutputStream bytes = new ByteArrayOutputStream();     inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);     String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);     return Uri.parse(path); } 

P.S. : I have answered a similar question here

like image 37
Akhil Avatar answered Oct 14 '22 10:10

Akhil