0

Following is the order of execution of my game which accesses Google Play services.

STEP1: Google Sign-In Screen with two available users is displayed. (USER1 and USER2)

STEP2: A user is selected and logged in successfully.

STEP3: The user plays the game. The "RESULTS" are stored locally with "Preference".

RESULTS include a)score and b)highestAchievementToBeUnlocked

After a successful login, or on end of a game, the achievement details are read from the file and fed to the Google console.

I am okay with the above steps, but confused with the following situation.

a) The user Signed IN as "USER1", played the game,the achievement details are fed to Google services.

b) The user Signed OFF and logged in as "USER2" and started gaming, details are fed to Google services.

c) Repeated Step a)

Please guide me to decide the best way to handle the above situation. How can I program in such a way that I could allow "USER1" to continue gaming with his previous achievements even though "USER2" had made an intermediate gaming with his account?

Thanks In Advance !!

VARUN ISAC
  • 443
  • 3
  • 13

1 Answers1

1

What you are trying to do should be covered by signing-in a Google Account. In most cases this is also the account that is signed-in to your Play Store.

Basically, if you have a logged in Google account in your device, achievements will be saved on that account.

As stated here:

Once the player is signed in and the GoogleApiClient is connected, your game can start using the achievements APIs.

Then you can just implement Signing Out to your game to make way for different accounts.

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.

SwagBomb
  • 584
  • 3
  • 7