TypeANumber project: UI not updating when logging off from Achievements or Leaderboard Activity
When you show the achievements or leaderboard activity and click on "settings" in the upper right corner and logoff, you will return to main_activity.xml where the UI still shows you are logged in.
Good catch! We have a fix in the works, expect it in the coming weeks. In the meantime you can use this workaround. Handling the resultCode of GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED will indicate that the user has signed out, so in this situation, you can use this to manually sign out.
Once the fix is in, you can remove this workaround. I'll update this ticket when the fix is live.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
signOut();
}
}
I'm running into the same issue. Even worse, if I can't catch the activity result, my client gets stuck in a state where it believes it is signed in, but is not. Ie. in this state:
- silentSignIn() returns com.google.android.gms.common.api.ApiException: 4
- getLastSignedInAccount returns non-null (indicating that i'm still logged in)
- getAllLeaderboardsIntent() returns a failure of com.google.android.gms.common.api.ApiException: 4
- signOut() crashes(!) my application with the following exception:
02-17 16:18:49.011 E/AndroidRuntime( 1554): Process: com.limbic.revenant, PID: 1554
02-17 16:18:49.011 E/AndroidRuntime( 1554): java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.common.internal.zzd.zzaka(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.common.internal.zzd.zzakb(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.games.internal.GamesClientImpl.zzg(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.games.internal.GamesClientImpl.zza(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.common.api.internal.zzbr.signOut(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.common.api.internal.zzbp.zzaih(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at com.google.android.gms.common.api.internal.zzbp.handleMessage(Unknown Source)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at android.os.Handler.dispatchMessage(Handler.java:98)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at android.os.Looper.loop(Looper.java:154)
02-17 16:18:49.011 E/AndroidRuntime( 1554): at android.os.HandlerThread.run(HandlerThread.java:61)
The only way around this I've found so far is to:
- (A) add the code above, and manually call signOut (which doesn't crash when called from onActivityResult)
- (B) detect this state (by waiting for the ApiException 4 to appear when querying leaderboards, etc) and then calling signIn() again (which re-signs the player). Note that I have to disable the check to see if I'm already signed in, as that returns true.
All in all, this cost me quite a bit of time and I don't feel very confident that this solution is robust. While this is probably a corner case (as very few players will sign out from the leaderboard intent), it currently makes the otherwise smooth integration somewhat nasty & hacky, so a fix would be very welcome :-)