新的Google+(加),照片应用程序下载图像 [英] Download image from new Google+ (plus) Photos Application

查看:128
本文介绍了新的Google+(加),照片应用程序下载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近日加入谷歌的照片应用程序使用Google+(加),它出现在你推出一个意向选择图像。但是,如果我选择从Google+相册的图像,并尝试使用它在我目前的逻辑我的申请没有能够返回一个可用的URI或URL真正得到,我可以下载和处理图像。我目前使用的普通的方法来试图操纵,可以在这里对堆栈溢出和其他地方发现的URI。如果需要,我可以提供code,但在这一点上,我认为这是一种不相关的,因为它可以很好地用于一切,除了这个新的应用程序。如何获得一个可用的图像任何想法?

的URI看起来是这样的:

<$p$p><$c$c>content://com.google.android.apps.photos.content/0/https%3A%2F%2Flh5.googleusercontent.com%<a一串字母和数字在这里 - GT;

MediaColumns.DATA 信息总是返回null和 MediaColumns.DISPLAY_NAME 总是返回image.jpg的不管是什么我从谷歌照片应用程序中进行选择。如果我试图粘贴一切从https到结束我的浏览器,没有出现。不知道如何得到有用的信息来源于此。

解决方案

在接收到数据的意图,你应该使用ContentResolver的拿到照片。 下面是你应该做的:

 字符串URL = intent.getData()的toString()。
点阵位图= NULL;
InputStream的是= NULL;
如果(url.startsWith(内容://com.google.android.apps.photos.content)){
       是= getContentResolver()openInputStream(Uri.parse(URL))。
       位= getBitmapFromInputStream(是);
}
 

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.

解决方案

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 = getBitmapFromInputStream(is);
}

这篇关于新的Google+(加),照片应用程序下载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆