GoogleSignInAccount getPhotoUrl()返回null [英] GoogleSignInAccount getPhotoUrl() return null

查看:127
本文介绍了GoogleSignInAccount getPhotoUrl()返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从已登录的个人资料中获取照片.但始终返回null.名称和电子邮件返回值,仅对照片有问题.

Trying to get photo from signed in profile. But always return null. Name and email return values, trouble only with photo.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestProfile()
            .requestEmail()
            .build();
mGoogleApiClient = new GoogleApiClient.Builder(StartActivity.this)
            .enableAutoManage(StartActivity.this, StartActivity.this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)   
            .build();
acct = gResult.getSignInAccount();
String name = acct.getDisplayName(); //okay, value != null
String email = acct.getEmail(); //okay, value != null
Uri photoUri = acct.getPhotoUrl() //not okay, value == null

为什么会这样?帐户已签名,电子邮件和姓名都可以,但是照片总是失败.

Why does it happen so? Account signed, email and name got, but photo always fail.

推荐答案

根据

公共Uri getPhotoUrl()

public Uri getPhotoUrl ()

获取已登录用户的照片网址.

Gets the photo url of the signed in user.

返回

照片网址.如果配置了requestProfile()并且用户确实具有Google+个人资料,则只有非null 图片.

photo url for the Google account. Only non-null if requestProfile() is configured and user does have a Google+ profile picture.

请检查您的Google帐户是否有Google+个人资料照片.

Please check if your Google account has had Google+ profile picture or not.

P/S:有时候,如果已经创建了Google+个人资料图片,但是在您将Google帐户添加到设备中之后,也许您需要从设备中删除该现有的Google帐户,然后重新添加.

这篇关于GoogleSignInAccount getPhotoUrl()返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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