I'm trying to implement leaderboard in my game.
I wrote this code:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
mGoogleApiClient.connect();
//....
while(!mGoogleApiClient.isConnected())Log.d("","NO CONNECTED");
Games.Leaderboards.submitScore(mGoogleApiClient, "MY_LEADERBOARD_ID",newscore);
Why mGoogleApiClient.isConnected()
returns always false?
EDIT1: Ok, now it works (I have changed Drive.API
with Games.API
and Drive.SCOPE_FILE
with Games.SCOPE_GAME
) but when I call submitScore()
even if it's all ok in the Log, the leaderboard is still empty. How can I check if submitScore()
really works?
EDIT2: I used
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, "MY_LEADERBOARD_ID"), REQ_LEADERBOARD);
and everything works!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…