问题
I'm working on a big application and I have to take the player's rank from the Google Play services' leaderboard. The leaderboard works well. I've already found the right method but I don't know how I'm supposed to use it:
private void loadRankOfLeaderBoard() {
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(mGoogleApiClient, getResources().getString(R.string.leaderboard_leaderboard), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
@Override
public void onResult(final Leaderboards.LoadPlayerScoreResult scoreResult) {
if (isScoreResultValid(scoreResult)) {
rank = (int)scoreResult.getScore().getRank();
}
}
});
}
But the onResult
callback is never called. Where am I supposed to call the function loadRankOfLeaderBoard?? I tried to put it in the onCreate
and in the onActivityResult
...
Thanks for your help!
回答1:
Okay, I finnaly found solution ... here for curious
So if you have the same problem, you have to put the function loadRankOfLeaderBoard on the function "onConnected" which will be call when you connect your device at google play service.
来源:https://stackoverflow.com/questions/37610936/how-to-get-rank-from-google-play-game-services-leaderboard