0

I had add 10 google play leaderboards in my libgdx app. Now I want to get player's rank from each leaderboards. I use this function:

private void loadRankOfLeaderBoard(final int level) {
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(_gameHelper.getApiClient(), getResources(). getString(LEADER_BOARDS.get(level-1)), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
        @Override
        public void onResult(Leaderboards.LoadPlayerScoreResult scoreResult) {
            if(isScoreResultValid(scoreResult)){
                rank.add(level-1, (int)scoreResult.getScore().getRank());
                Log.d("COUCOU", "isScoreResultValid "+(level));

            }
            else{
                rank.add(level-1, -1);
                Log.d("COUCOU", "NOTisScoreResultValid "+(level) + " GamesStatusCodes." + (scoreResult.getStatus().getStatusMessage()));

            }
        }
    });     
}
private boolean isScoreResultValid(Leaderboards.LoadPlayerScoreResult scoreResult) {
    return scoreResult != null && GamesStatusCodes.STATUS_OK == scoreResult.getStatus().getStatusCode() && scoreResult.getScore() != null;
}

and I use it in the onCreate like this:

GameHelperListener gameHelperListener = new GameHelper.GameHelperListener(){
        @Override
        public void onSignInSucceeded(){
            for(int i = 0; i < LEADER_BOARDS.size(); i++){
                loadRankOfLeaderBoard(i+1);
            }

        }

        @Override
        public void onSignInFailed(){
        }

    };

    _gameHelper.setup(gameHelperListener);

And the Log result is that:

06-30 21:59:01.216: D/COUCOU(21238): isScoreResultValid 1
06-30 21:59:01.703: D/COUCOU(21238): isScoreResultValid 2
06-30 21:59:02.147: D/COUCOU(21238): isScoreResultValid 3
06-30 21:59:02.370: D/COUCOU(21238): NOTisScoreResultValid 4 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:02.584: D/COUCOU(21238): NOTisScoreResultValid 5 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:02.822: D/COUCOU(21238): NOTisScoreResultValid 6 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:03.119: D/COUCOU(21238): NOTisScoreResultValid 7 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:03.448: D/COUCOU(21238): NOTisScoreResultValid 8 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:03.740: D/COUCOU(21238): NOTisScoreResultValid 9 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA
06-30 21:59:04.031: D/COUCOU(21238): NOTisScoreResultValid 10 GamesStatusCodes.STATUS_NETWORK_ERROR_NO_DATA

So as you can see, the first three leaderboards work well, but the 7 others dont't work. Sometime, no one of the 10 work. It's so strange.

Thanks you for help !

Benjamin Lucidarme
  • 1,648
  • 1
  • 23
  • 39
  • `A network error occurred while attempting to retrieve fresh data, and no data was available locally.` It seems like you are having connectivity issues. – Nick Felker Jul 01 '16 at 00:45
  • Of course I look in that way, but if there was a network error, even the first 3 wouldn't work and the other 7 woudl work sometime, whereas they never work. It's that why it's really strange... – Benjamin Lucidarme Jul 01 '16 at 08:16
  • Was facing the same issue, looks like this was answered here: http://stackoverflow.com/questions/33995922/android-google-play-service-leaderboard-limited-number-of-requests – John Oct 13 '16 at 22:54

0 Answers0