load-CurrentPlayerLeaderboardScore 总是失败
load-CurrentPlayerLeaderboardScore is always failure
我想让用户在 Playstore 中获得最后的分数,但我研究了 2 天但一无所获。最后,我写了代码(我不确定它会不会是错误的代码)但总是失败。
写入 load-CurrentPlayerLeaderboardScore 删除 fk17bH1SYLoBdGsBaDedPR2EE3JUt8oRS7qd 的“-”
这是代码;
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();
}
});
谢谢你帮助我
根据这些链接 and 2,调用过多可能会导致此类错误。建议采取的措施是避免过度滥用播放服务。此外,您可以尝试分散您的请求,而不是一次提出所有请求。
我想让用户在 Playstore 中获得最后的分数,但我研究了 2 天但一无所获。最后,我写了代码(我不确定它会不会是错误的代码)但总是失败。
写入 load-CurrentPlayerLeaderboardScore 删除 fk17bH1SYLoBdGsBaDedPR2EE3JUt8oRS7qd 的“-”
这是代码;
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();
}
});
谢谢你帮助我
根据这些链接