GoogleSignIn.getLastSignedInAccount() 返回具有空字段的帐户
Posted
技术标签:
【中文标题】GoogleSignIn.getLastSignedInAccount() 返回具有空字段的帐户【英文标题】:GoogleSignIn.getLastSignedInAccount() returns account with null fields 【发布时间】:2018-06-25 20:34:06 【问题描述】:我正在我的项目中实现 Google 登录,但这个问题很困难。当我没有签名时,GoogleSignIn.getLastSignedInAccount(activity)
返回null
,这是它应该做的,根据Google's documentation。当我重新启动应用程序时,它返回一个GoogleSignInAccount
,但所有字段均为null
。
谷歌说:
有关可能可用的其他个人资料数据,请参阅 GoogleSignInAccount。请注意,任何配置文件字段都可以为空,具体取决于您请求的范围以及用户配置文件包含的信息。
所以我认为问题在于缺少请求的信息,但我之前正确地定义了它们:
GoogleSignIn.getClient(activity, GoogleSignInOptions.Builder()
.requestId()
.requestProfile()
.requestEmail()
.build()
);
此外,在使用上述相同的客户端请求注册后,所有信息都以完美的GoogleSignInAccount
形式出现。
【问题讨论】:
【参考方案1】:在我的游戏中,当 GoogleSignIn.getLastSignedInAccount(activity) 返回 null 时,我调用 startSigninIntent:
private void startSignInIntent()
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
【讨论】:
谢谢哥们,就我而言,我使用了 GoogleSignInOptions.DEFAULT_SIGN_IN。干杯...以上是关于GoogleSignIn.getLastSignedInAccount() 返回具有空字段的帐户的主要内容,如果未能解决你的问题,请参考以下文章