I am new to Android App development. I want to retrieve user's score from Google Play Game service and i am using following code to get the high score but i do not have any knowledge how it returns the value and how to save it.
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(getApiClient(), getString(R.string.highscore), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC);
Saving it to int or string does not worked.
The complete parameters for loadCurrentPlayerLeaderboardScore is like below
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(getApiClient(),
getString(R.string.word_attack_leaderboard),
LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(
new ResultCallback<LoadPlayerScoreResult>() {
@Override
public void onResult(LoadPlayerScoreResult arg0) {
LeaderboardScore c = arg0.getScore();
long score = c.getRawScore();
}
}
R.string.word_attack_leaderboard is leaderboards id which get from google play game service
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With