Top 5 scores from google leaderboard

前端 未结 4 470
粉色の甜心
粉色の甜心 2020-12-14 13:47

My requirement is to get top 5 scores from leaderboard and display it in my app.

There is a method loadTopScores but it shows the scores in its own UI i guess.

4条回答
  •  情深已故
    2020-12-14 14:07

    My Solution which worked is as follows which is for the latest game play services.

      Games.Leaderboards.loadTopScores(mGamesClint,LEADERBOARD_ID, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, 5).setResultCallback(new ResultCallback() {
    
            public void onResult(LoadScoresResult arg0) {
                // TODO Auto-generated method stub
    
                int size = arg0.getScores().getCount();
    
    
    
                for ( int i = 0; i < 3; i++ )  {
    
                    LeaderboardScore lbs = arg0.getScores().get(i);
    
                    String name = lbs.getScoreHolderDisplayName();
    
                    String score = lbs.getDisplayScore();
    
                    Uri urlimage = lbs.getScoreHolderHiResImageUri();
    
                     }
    
     }
    

    you can get all the data from leaderboard users here including high resolution image ie. profile picture. Hope you get the idea here.

提交回复
热议问题