Android Google Play排行榜

时间:2017-08-30 03:27:22

标签: android google-play google-play-services google-play-games leaderboard

我开发了一款安卓游戏。我在游戏中使用了Google Play排行榜。 我的问题是排行榜得分没有显示在应用程序中。排行榜界面出现,但说“没有这个游戏的排行榜”。用户评分不会出现。

这是保存分数代码

PendingResult<Leaderboards.LoadPlayerScoreResult> result = Games.Leaderboards.loadCurrentPlayerLeaderboardScore(getApiClient(),getString(R.string.number_guesses_leaderboard), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC);
                        result.setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
                            @Override
                            public void onResult(Leaderboards.LoadPlayerScoreResult loadPlayerScoreResult) {
                                if(loadPlayerScoreResult != null && loadPlayerScoreResult.getScore() != null) {
                                    Games.Leaderboards.submitScore(getApiClient(), getString(R.string.number_guesses_leaderboard), loadPlayerScoreResult.getScore().getRawScore() + value);}
                                else {
                               Games.Leaderboards.submitScore(getApiClient(), getString(R.string.number_guesses_leaderboard), value); }
                            }}); 

任何想法?我该怎么做?

1 个答案:

答案 0 :(得分:1)

确保您已在Google Play控制台上正确设置排行榜。在那里,您将先Create your Leaderboard,然后Add Leaderboard to your game