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.
write load-CurrentPlayerLeaderboardScore delete the "-" for fk17bH1SYLoBdGsBaDedPR2EE3JUt8oRS7qd
this is the code;
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.loadCurrentPlayerLeaderboardScore(
"CgkIiMyT6f0SEAIQHg", LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_PUBLIC)
.addOnSuccessListener(this, new OnSuccessListener<AnnotatedData<LeaderboardScore>>(){
@Override
public void onSuccess(AnnotatedData<LeaderboardScore> leaderboardScoreAnnotatedData) {
if (leaderboardScoreAnnotatedData != null) {
long score = 0;
if (leaderboardScoreAnnotatedData.get() != null) {
score = leaderboardScoreAnnotatedData.get().getRawScore();
Toast.makeText(MenuActivity.this, Long.toString(score), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(MenuActivity.this, "null 2", Toast.LENGTH_SHORT).show();
} else
Toast.makeText(MenuActivity.this, "null 1", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MenuActivity.this, "addOnFailureListener", Toast.LENGTH_SHORT).show();
}
});
Thanks for helping me