新的Google+(加),照片应用程序下载图像应用程序、图像、照片、Google

2023-09-13 00:04:23 作者:久了久了就旧了°

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

的URI看起来是这样的:

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(是);
}
 
谷歌推出全新照片搜索应用 展示Flutter应用新特性

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);
}