在Android中获取Google个人资料图片

时间:2015-03-17 13:37:28

标签: android image google-plus

目前是否有可能获得 Google个人资料图片并将其绘制在ImageView?我一直在寻找谈论此事的帖子,但我还没有找到它。

2 个答案:

答案 0 :(得分:3)

在不使用谷歌API密钥的情况下提供谷歌+个人资料照片

http://picasaweb.google.com/data/entry/api/user/any_name?alt=json

然后你可以在json中获取img url并删除' s64-c'部分来自网址和 追加"?sz = 100"参数(100或更大尺寸)

http://lh6.ggpht.com/-gAabIEudGQw/AAAAAAAAAAI/AAAAAAAAAAA/n062zUtBx4k/s64-c/101417311204099987701.jpg

答案 1 :(得分:0)

我认为您需要做的是验证并使用其中一个Google+ OAuth范围(我认为这将是plus.login),以获取个人资料图片网址:https://developers.google.com/+/api/oauth#scopes

您可以使用GoogleApiClient进行此操作。看看文档。或者查看问题评论中的链接 https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html

之后,您可以使用像Picasso这样的库将图像从URL加载到ImageView中:http://square.github.io/picasso/

Picasso.with(context).load(pictureUrl).into(imageView);
相关问题