Google Play 服务 - 在一台设备上处理多个帐户
Google Play Services -Handling Multiple Accounts On a single device
以下是我的游戏访问 Google Play 服务的执行顺序。
第 1 步:Google 显示有两个可用用户的登录屏幕。 (用户 1 和用户 2)
第 2 步:选择用户并成功登录。
STEP3:用户玩游戏。 "RESULTS" 与 "Preference" 在本地存储。
结果包括 a)score
和 b)highestAchievementToBeUnlocked
成功登录后或游戏结束时,将从文件中读取成就详细信息并将其提供给 Google 控制台。
我对上面的步骤没问题,但对下面的情况感到困惑。
a) 用户以 "USER1" 身份登录,玩了游戏,成就详情被提供给 Google 服务。
b) 用户注销并以 "USER2" 身份登录并开始游戏,详细信息将提供给 Google 服务。
c) 重复步骤 a)
请指导我决定处理上述情况的最佳方法。
我怎样才能以允许 "USER1" 继续玩他以前的成就的方式进行编程,即使 "USER2" 已经用他的帐户进行了中级游戏?
提前致谢!!
您尝试做的事情应该由 signing-in 一个 Google 帐户涵盖。在大多数情况下,这也是登录您的 Play 商店的帐户。
基本上,如果您的设备中有登录的 Google 帐户,成就将保存在该帐户中。
如前所述here:
Once the player is signed in and the GoogleApiClient is connected,
your game can start using the achievements APIs.
然后你可以在你的游戏中实现 Signing Out 来为不同的帐户让路。
Call signOut()
to sign the user out of the Google Play games services.
If your game is using other Google Play services, make sure to also
sign the user out of those services (for example, call
clearDefaultAccount()
to sign-out of the Google+ service). Also, your
game should set a flag to indicate that the user explicitly signed
out, then check that flag the next time the game activity's onStart()
method is called. Based on the flag value, your game can then
determine whether or not to call connect()
to sign the user in.
以下是我的游戏访问 Google Play 服务的执行顺序。
第 1 步:Google 显示有两个可用用户的登录屏幕。 (用户 1 和用户 2)
第 2 步:选择用户并成功登录。
STEP3:用户玩游戏。 "RESULTS" 与 "Preference" 在本地存储。
结果包括 a)score
和 b)highestAchievementToBeUnlocked
成功登录后或游戏结束时,将从文件中读取成就详细信息并将其提供给 Google 控制台。
我对上面的步骤没问题,但对下面的情况感到困惑。
a) 用户以 "USER1" 身份登录,玩了游戏,成就详情被提供给 Google 服务。
b) 用户注销并以 "USER2" 身份登录并开始游戏,详细信息将提供给 Google 服务。
c) 重复步骤 a)
请指导我决定处理上述情况的最佳方法。 我怎样才能以允许 "USER1" 继续玩他以前的成就的方式进行编程,即使 "USER2" 已经用他的帐户进行了中级游戏?
提前致谢!!
您尝试做的事情应该由 signing-in 一个 Google 帐户涵盖。在大多数情况下,这也是登录您的 Play 商店的帐户。
基本上,如果您的设备中有登录的 Google 帐户,成就将保存在该帐户中。
如前所述here:
Once the player is signed in and the GoogleApiClient is connected, your game can start using the achievements APIs.
然后你可以在你的游戏中实现 Signing Out 来为不同的帐户让路。
Call
signOut()
to sign the user out of the Google Play games services. If your game is using other Google Play services, make sure to also sign the user out of those services (for example, callclearDefaultAccount()
to sign-out of the Google+ service). Also, your game should set a flag to indicate that the user explicitly signed out, then check that flag the next time the game activity'sonStart()
method is called. Based on the flag value, your game can then determine whether or not to callconnect()
to sign the user in.