Exit google play Game service Leaderboard

When the leaderboard is displayed on the screen, the “setup” option appears. Inside there is an option "Exit". When I clicked the icon, the leaderboard is closed,

Issue.

If I checked the status of the character, the function below returns true. Means that mGoogleApiClient is connected. and therefore when I tried to click on the icon that shows the leaderboard, it always has responseCode RESULT_RECONNECT_REQUIRED.

This problem disappears if I restart my application

public boolean isSignedIn() {
    return mGoogleApiClient != null && mGoogleApiClient.isConnected();
}

Question.

How does the program know that the user has logged into the leaderboard screen.

+4
source share
2

onActivityResult GoogleApiClient.disconnect() , ().

, , :

activity.startActivityForResult(Games.Leaderboards.getLeaderboardIntent(googleApiClient, leaderboardId), MY_CUSTOM_LEADERBOARD_RESULT_CODE);

:

public void onActivityResult(int requestCode, int responseCode, Intent intent) {
    boolean userLoggedOut = (responseCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) && (requestCode == MY_CUSTOM_LEADERBOARD_RESULT_CODE);
    if (userLoggedOut) {
        googleApiClient.disconnect();
    }
}
+6

RESULT_RECONNECT_REQUIRED, reconnect().

, . , onConnectionFailed(), reset / .

   if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
       mGoogleApiClient.reconnect();

   }
+2

Source: https://habr.com/ru/post/1615198/


All Articles