Open kadirboz opened 6 years ago
Hi @kadirboz, what error are you seeing?
Try printing out more details of the failure exception like in the Type A Number Sample.
Without more information, just by looking at your code, getLastSignedInAccount might not be returning a valid account.
Ah yes! Well it seems there is a quota restriction bug, never addressed with loadCurrentPlayerLeaderboardScore. You are restricted per user to 3 requests. No more per session/activity.
I would suggest another approach I have discovered as there seems to be no other
User loadPlayerCenteredScores. Limit the scores to 1. The resultant buffer will return only the player score. Fixed
leaderboardName = getString(R.string.leaderboard_name); // or string of ID
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.loadPlayerCenteredScores(leaderboardName, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, 1)
.addOnSuccessListener(new OnSuccessListener<AnnotatedData<LeaderboardsClient.LeaderboardScores>>() {
@Override
public void onSuccess(AnnotatedData<LeaderboardsClient.LeaderboardScores> leaderboardScoreAnnotatedData) {
LeaderboardsClient.LeaderboardScores scoresResult = leaderboardScoreAnnotatedData.get();
LeaderboardScore scoreResult = (scoresResult != null ? scoresResult.getScores().get(0) : null);
long score = 0;
if(scoreResult != null) score = scoreResult.getRawScore();
gameStatsOutbox.setLeaderboard(score, leaderboardNumber); // if using example / change this to set the result score
Log.i(TAG, "GPGuS:Leader:" + leaderboardNumber + " score:" + score);
leaderboardScoreAnnotatedData = null;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(TAG, "Failure:getLeaderboardScoreUnScoped GPG:Leader:" + leaderboardNumber + " Ex:" + e.getMessage());
}
i wanna get users get last score in playstore but i research 2 days and i got nothing. Finally, i wrote the code (i'm not sure it'll be wrong code) but always get failure.
and i'm asking a question. why getting current player score is so hard? submitscore is very easy, why getting score is not like submitting score?
please add getScore function like submitScore