java–GoogleSignIn.getLastSignedInAccount()返回带有空字段的帐户

java–GoogleSignIn.getLastSignedInAccount()返回带有空字段的帐户,第1张

概述我正在我的项目中实施Google登录,但这个问题很难解决.根据Google’sdocumentation,当我没有签名时,GoogleSignIn.getLastSignedInAccount(activity)将返回null,这应该是它应该做的.当我重新启动应用程序时,它返回一个GoogleSignInAccount,但所有字段都为null.谷歌说:Foradditi

我正在我的项目中实施Google登录,但这个问题很难解决.根据Google’s documentation,当我没有签名时,GoogleSignIn.getLastSignedInAccount(activity)将返回null,这应该是它应该做的.当我重新启动应用程序时,它返回一个GoogleSignInAccount,但所有字段都为null.

谷歌说:

For additional profile data that might be available, see GoogleSignInAccount. Note that any of the profile fIElds can be null, depending on which scopes you requested and what information the user’s profile includes.

所以我认为问题是缺少所要求的信息,但我之前正确地定义了它们:

GoogleSignIn.getClIEnt(activity, GoogleSignInoptions.Builder()    .requestID()    .requestProfile()    .requestemail()    .build());

此外,使用上述相同的客户请求注册后,所有信息都会出现在完美的GoogleSignInAccount中.

解决方法:

在我的游戏中,当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);}
总结

以上是内存溢出为你收集整理的java – GoogleSignIn.getLastSignedInAccount()返回带有空字段的帐户全部内容,希望文章能够帮你解决java – GoogleSignIn.getLastSignedInAccount()返回带有空字段的帐户所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1118505.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存