Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Score of user from Google Play Game Service?

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.

like image 538
Sudeep Acharya Avatar asked Dec 05 '22 07:12

Sudeep Acharya


1 Answers

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

like image 188
Plugie Avatar answered Dec 10 '22 11:12

Plugie