android – GoogleSignInAccount getPhotoUrl()返回null

尝试从登录配置文件获取照片.但总是返回null.名称和电子邮件返回值,只有照片才有麻烦.
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

为什么会这样发生?帐号已经签名,电子邮件名称已经得到,但照片总是失败.

解决方法

根据 Google’s documentation – GoogleSignInAccount

public Uri getPhotoUrl ()

Gets the photo url of the signed in user.

Returns

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

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

P / S:有时,如果Google个人资料照片已经创建,但在您的设备中添加Google帐户后,您可能需要从设备中删除现有的Google帐户,然后重新添加.

相关文章

Android 通过adb shell命令查看内存,CPU,启动时间,电量等...
Monkey Android app稳定性测试工具之Monkey使用教程 by:授客...
Android 常见adb命令 by:授客 QQ:1033553122 1、 查看所有已...
这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...