Google 玩游戏服务 BaseGameUtils 错误
Google Play Game Services BaseGameUtils bug
我做了一个 Android 项目,我想在其中使用 GPGS。我立项了,取得了一些成绩。我使用 BaseGameUtils
库作为基础。一开始,应用程序询问我想使用哪个帐户,一切顺利。
我可以使用以下代码打开成就 activity:
if (gameHelper.isSignedIn()) {
startActivityForResult(Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 101);
} else if (!gameHelper.isConnecting()) {
loginGPGS();
}
但是,如果我在那里,打开 activity 中的选项菜单并注销,然后尝试再次打开成就,我的应用程序就会崩溃,并显示一条关于我应该登录的消息在试图得到它们之前。虽然这是真的,但我认为如果用户已登录,gameHelper.isSignedIn()
应该只 return 为真。BaseGameUtils
是坏了,还是我遗漏了什么?
这正是 on the Github issue tracker 提出的问题。最后的回复是:
This is actually not a bug - it's working as intended.
When you start a GPGS activity, you have to start it with startActivityForResult
. If the user clicks on sign-out, the GoogleApiClient
is NOT disconnected - it's just in a "signed out" state. The onActivityResult
here will return a status RECONNECT_REQUIRED
. At this point, the developer should reconnect their client, and life goes on as expected.
我做了一个 Android 项目,我想在其中使用 GPGS。我立项了,取得了一些成绩。我使用 BaseGameUtils
库作为基础。一开始,应用程序询问我想使用哪个帐户,一切顺利。
我可以使用以下代码打开成就 activity:
if (gameHelper.isSignedIn()) {
startActivityForResult(Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 101);
} else if (!gameHelper.isConnecting()) {
loginGPGS();
}
但是,如果我在那里,打开 activity 中的选项菜单并注销,然后尝试再次打开成就,我的应用程序就会崩溃,并显示一条关于我应该登录的消息在试图得到它们之前。虽然这是真的,但我认为如果用户已登录,gameHelper.isSignedIn()
应该只 return 为真。BaseGameUtils
是坏了,还是我遗漏了什么?
这正是 on the Github issue tracker 提出的问题。最后的回复是:
This is actually not a bug - it's working as intended.
When you start a GPGS activity, you have to start it with
startActivityForResult
. If the user clicks on sign-out, theGoogleApiClient
is NOT disconnected - it's just in a "signed out" state. TheonActivityResult
here will return a statusRECONNECT_REQUIRED
. At this point, the developer should reconnect their client, and life goes on as expected.