Google Play游戏排行榜没有刷新

时间:2018-10-05 10:54:12

标签: java android google-play google-play-games leaderboard

在我的游戏的个人资料活动中,我加载了用户的得分并从玩游戏排行榜中的TextView中排名,并且在首次加载该应用程序时效果很好,但是在玩完游戏之后,当用户重新访问个人资料活动时,得分仍然保持即使排行榜中的分数更新,但TextViews却没有。

这是我的代码,用于从排行榜加载得分。

 Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)).
         loadCurrentPlayerLeaderboardScore(getString(R.string.leaderboard_high_score),
                 LeaderboardVariant.TIME_SPAN_ALL_TIME,LeaderboardVariant.COLLECTION_PUBLIC).addOnCompleteListener(new OnCompleteListener<AnnotatedData<LeaderboardScore>>() {
     @Override
     public void onComplete(@NonNull Task<AnnotatedData<LeaderboardScore>> task) {

            if (task.isSuccessful() ) {

                String overAllRank = task.getResult().get().getDisplayRank();
                String overAllScore = task.getResult().get().getDisplayScore();

                mOverAllPoints.setText(overAllScore);
                mOverAllRank.setText(overAllRank);



                Log.i("UserScore", overAllScore + " " + overAllRank);

            } 

玩完游戏后,我使用此代码上传用户的分数

 Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
            .submitScore(getString(R.string.leaderboard_high_score), score);

如果有人可以告诉我如何在TextView中更新分数,那将非常有帮助。

0 个答案:

没有答案
相关问题