Skip to content Skip to sidebar Skip to footer

How To Handle Disconnect From Google Game Services?

I use Google Game Services for leaderboards. Showing it like this: static public void showLeaderboard(String lid) { if (isLogined() == 1) { Log.i(TAG, 'Showing leaderboard.

Solution 1:

In order to keep everything synced up you MUST implement onActivityResult properly.

This should look something as follows:

@OverrideprotectedvoidonActivityResult(int request, int response, Intent data) {

   // check for "inconsistent state"if ( responseCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED && requestCode == <your_request_code_here> )  {  
      // force a disconnect to sync up state, ensuring that mClient reports "not connected"
      mClient.disconnect();
   }
}

NOTE: just make sure to replace <your_request_code_here> in the code with the request code you used (which is just 1 in your example). You may need to check for multiple request codes if you use achievements as well.

Solution 2:

Simply trycatching the showLeaderbord method works fine as well by adding .disconnect and .connect, and then try again in the catch body

Post a Comment for "How To Handle Disconnect From Google Game Services?"