谷歌玩游戏服务 - 未登录的下一个活动 [英] Google Play Game Services - not signed in on next activity

查看:201
本文介绍了谷歌玩游戏服务 - 未登录的下一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我在游戏中帮助(我想在按钮点击登录):

In my application, i have in game helper(i want log in on button click):

// Whether to automatically try to sign in on onStart(). We only set this
// to true when the sign-in process fails or the user explicitly signs out.
// We set it back to false when the user initiates the sign in process.
boolean mConnectOnStart = false;

在我MainActivity(延伸BaseGameActivity),登录按钮后点击我打电话:

In my MainActivity (extends BaseGameActivity), after login button click i call:

beginUserInitiatedSignIn();             

当然,现在isSignedIn()返回true。

Of course now isSignedIn() returns true.

但是,当我去到下一个活动(aslo延伸BaseGameActivity): isSignedIn()返回false。

But when I go to next Activity (aslo extends BaseGameActivity): isSignedIn() return false.

我当然可以调用beginUserInitiatedSignIn()在我的下一个活动,但我不'吨想要它。 在我的应用程序的用户可以登录,但不是必须的。所以,如果没有登录的用户在我的mainActivity这个我不希望在接下来的活动显示登录表单。

I can of course call beginUserInitiatedSignIn() on my next Activity, but i don' t want it. In my app user can be logged in, but not have to. So if user not logged in at my mainActivity i don' t want show login form on next activity.

编辑:这一刻我的解决方案是创建静态变量,并设置它,当我离开我的主要活动为TURE如果isSignedIn(),并调用beginUserInitiatedSignIn()的下一个活动,只有当这个变量是真实的。难道没有更好的,自动的解决方案?

For this moment my solution is to create static variable and set it when i leave my main activity for ture if isSignedIn() and call beginUserInitiatedSignIn() on next activity only when this variable is true. Is it any better, automatic solution ?

推荐答案

有两种标志的:

  1. 在用户启动的迹象,其中显示了谷歌Play游戏标志,并要求用户批准访问,等等。
  2. 在寂静的符号(其中 BaseGameActivity 确实在其 ONSTART 通话) - 这会自动尝试登录,然后,如果用户已经登录,做了同样的回调,如果你通过流量用户启动的迹象已经走了。
  1. The user initiated sign in which shows the Google Play Games logo and requires the user to approve access, etc.
  2. Silent sign in (which BaseGameActivity does in its onStart call) - this automatically attempts to sign in and, if the user has already signed in, does the same callback as if you had gone through the user initiated sign in flow.

所以您需等待登录的回调尝试任何谷歌玩游戏在每一个活动有关的电话前。

Therefore you do need to wait for the sign in callback before attempting any Google Play Games related calls in each and every activity.

需要注意的是(在2014年2月18日5天前)近日, BaseGameUtils库为Android 已更新为使用新的谷歌API客户的模型,它可以让你在签字之前,务必阅读调用(在那里他们将自动等到登录尝试处理之前)。由于谷歌API客户给出了许多其他的好处(如提高可靠性标志),你应该升级到最新的 BaseGameUtils 如果您还没有。

Note that recently (4 days ago on Feb 18, 2014), the BaseGameUtils library for Android was updated to use the new Google Api Client model, which allows you to do read calls before being signed in (where they will automatically wait until sign in before attempting to process). As the Google Api Client gives a number of other benefits (such as improved sign in reliability), you should update to the latest BaseGameUtils if you haven't already.

这篇关于谷歌玩游戏服务 - 未登录的下一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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