Google Play服务排行榜 - 仅在打开排行榜时发布评分

问题描述 投票:0回答:1

我有一个带有Leaderboard实现的Android游戏。我的问题是用户看起来一切都很好,他的分数仅在他打开排行榜时出现。在Activity中我在onCreate中调用它:

if (!isSignedIn()) {
        beginUserInitiatedSignIn();
    }
    if (getApiClient().isConnected()) {
        Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard), totalScoreLong);
    }

打开排行榜时:

if (!isSignedIn()) {
                beginUserInitiatedSignIn();
            } else {
                startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), getString(R.string.leaderboard)), 2);
            }

此外,当用户在游戏中完成一轮时,我尝试发送更新的分数:

if (getApiClient().isConnected()) {
            Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard), totalLong);
        }

我究竟做错了什么?在打开它之前,我无法在引导板中看到用户....猜猜它不应该以这种方式工作,因为我已经看到其他应用程序有1000个用户,我不认为每个人都看到排行榜。我在应用程序上有很多用户,所以这不应该是问题,我也测试了2个设备,用户不可见。

android google-play-services leaderboard
1个回答
0
投票

您可以尝试使用Google Api而不是GoogleApiClient吗?通过这种方式,您可以摆脱处理可能存在问题的连接状态。

您还可以使用submitScoreImmediate方法,该方法将尝试异步加载分数并将结果返回给您。

例:

Games.getLeaderboardsClient(ctx, signIn)
    .submitScoreImmediate(id, score)
    .addOnSuccessListener(
      new OnSuccessListener<ScoreSubmissionData>() {
        @Override
        public void onSuccess(ScoreSubmissionData data) {
          ...
        }
      });
© www.soinside.com 2019 - 2024. All rights reserved.