Android排行榜将不会显示



我使用提交分数时没有任何错误

public void submitScore(int score)
{
    Games.Leaderboards.submitScore(mGoogleApiClient, "leaderboard_easy_leaderboard", score);
}

但当我运行显示排行榜代码时:

public void displayScores()
{
    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, "leaderboard_easy_leaderboard"), 0);
}

我收到以下错误:

11-07 17:00:39.873 32580-1830/? E/Volley: [161] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/games/v1/leaderboards/leaderboard_easy_leaderboard?language=en_US
11-07 17:00:39.882 32580-9774/? E/LeaderboardAgent: Unable to retrieve leaderboard leaderboard_easy_leaderboard
11-07 17:00:39.882 32580-9774/? E/LeaderboardAgent: No instance found for leaderboard leaderboard_easy_leaderboard for SOCIAL and ALL_TIME

googleapi链接显示以下文本:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Login Required",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Login Required"
 }
}

我所需要做的就是:

getString(R.string.leaderboard_easy_leaderboard)

代替:

"leaderboard_easy_leaderboard"

所以最终的解决方案是:

public void displayScores()
{
    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, getString(R.string.leaderboard_easy_leaderboard)), 0);
}

相关内容

  • 没有找到相关文章

最新更新