I made an Android project in which I'd like to use GPGS. I set up the project, made some achievements. I use the BaseGameUtils
library as a base. At the start, the application asks for which account I'd like to use, and everything is going well.
I could open the Achievements activity with this code:
if (gameHelper.isSignedIn()) {
startActivityForResult(Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 101);
} else if (!gameHelper.isConnecting()) {
loginGPGS();
}
However if I'm there, and I open the options menu in that activity and sign out, and I'm trying to open the achievements again, my application crashes with a message about I should log in before trying to get them. And while this is true, I assumed the gameHelper.isSignedIn()
should only return true, if the user is logged in. Is the BaseGameUtils
broken, or am I missing something?
This is the exact issue brought up on the Github issue tracker. The final response was:
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.