我没有看到我的XP授予用户。以下是截图:
以下是成就页面
这是排行榜:
以下是我从Google Play服务中调用成就和排行榜的代码: -
protected static final int REQUEST_LEADERBOARD = 1;
protected static final int REQUEST_ACHIEVEMENTS = 0;
@Override
public void onClick(View v) {
if (v.getId() == R.id.scoreButton)
{
counter++;
giveAchievements(counter);
textScore.setText(""+counter);
}
if(v.getId() == R.id.show_achievements)
{
startActivityForResult(Games.Achievements.getAchievementsIntent(getApiClient()), REQUEST_ACHIEVEMENTS);
}
if(v.getId() == R.id.show_leaderboard){
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(),
getString(R.string.leaderboard_leaderboard)), REQUEST_LEADERBOARD);
}
if (v.getId() == R.id.share)
{
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}
if (v.getId() == R.id.sign_in_button) {
beginUserInitiatedSignIn();
}
else if (v.getId() == R.id.sign_out_button) {
signOut();
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
}
}
以下是解锁成就的代码,但它没有向用户授予任何xp,正如您在上面的图片2中看到的那样我希望在用户获得某个'计数器时给予用户xp。评分: -
void giveAchievements(int counter)
{
if (counter == 10)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_first_10_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), "CgkI-eXOwZsFEAIQBg", counter);
}
if (counter == 50)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_50_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), "CgkI-eXOwZsFEAIQBg", counter);
} if (counter == 100)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_100_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
} if (counter == 250)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_250_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), "CgkI-eXOwZsFEAIQBg", counter);
} if (counter == 500)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_500_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
} if (counter == 1000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_1000_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
} if (counter == 1500)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_1500_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
} if (counter == 3000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_3000_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
} if (counter == 5000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_5000_clicks));
Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard_leaderboard), counter);
}
}