2015-11-07 101 views
3

使用提交我的成績時,我沒有任何錯誤: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 

googleapis鏈接顯示以下文本:

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

回答

1

所有我需要做的是:

getString(R.string.leaderboard_easy_leaderboard) 

相反的:

"leaderboard_easy_leaderboard" 

所以最終的解決方案是:

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