无法重温Google Play游戏服务排行榜得分

时间:2017-01-04 16:30:50

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

我希望从与Google Play游戏服务相关的排行榜中获得用户分数。我有6个排行榜,游戏只加载3个排行榜,其他排行榜数据我得到空。

if (mGoogleApiClient.isConnected()) {
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_score__normal_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                Log.d("myleader", "score normal : " + mGoogleApiClient.isConnected());
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    int s = (int) c.getRawScore();
                    Log.d("myleader", "score normal : " + s);
                }
            }
        });
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_time__normal_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    long s = c.getRawScore();
                    Log.d("myleader", "time normal : " + s);
                }
            }
        });
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_score__reverse_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    int s = (int) c.getRawScore();
                    Log.d("myleader", "score rev : " + s);
                }
            }
        });
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_time__reverse_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    long s = c.getRawScore();
                    Log.d("myleader", "time rev : " + s);
                }
            }
        });
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_time__zen_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    long s = c.getRawScore();
                    Log.d("myleader", "time zen : " + s);
                }
            }
        });
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient,
        getString(R.string.leaderboard_best_time__search_mode),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(
        new ResultCallback < Leaderboards.LoadPlayerScoreResult > () {
            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult arg0) {
                if (arg0.getScore() != null) {
                    LeaderboardScore c = arg0.getScore();
                    long s = c.getRawScore();
                    Log.d("myleader", "Time search : " + s);
                }
            }
        });

我在所有6个排行榜中都得分。 在前3个 arg0.getScore()非空并加载排行榜得分,但在最后3个排行榜中显示 arg0.getScore() null ...光标无法访问该函数中的日志编写器。

所有排行榜ID都是正确的我在发布之前已经检查了两次 提前谢谢。

0 个答案:

没有答案