简体   繁体   English

如何将获得的XP和成就添加到Google游戏个人资料?

[英]How to add gained xp and achievements to google game profile?

I have made a gaming app, and published it on google store and I have added google achievement xp to my app, but there is no guide on internet that I can find that should add player's earned xp on the google play game profile and also it(google game app) not showing achievements and xp it only shows the leaderboard. 我已经制作了一个游戏应用程序,并将其发布在Google商店上,并且已经将谷歌成就xp添加到了我的应用程序中,但是我找不到互联网上的指南,该指南应该将玩家获得的xp添加到Google Play游戏资料中,并且(Google游戏应用)不显示成就,而XP仅显示排行榜。

Here is my code :- 这是我的代码:-

void giveAchievements(int counter) {
if (counter == 10) {   
    int xp = getXp();
    xp += 500;
    saveXp(xp);
    if(getApiClient().isConnected()) {
        Games.Achievements.unlock(getApiClient(),   getString(R.string.achievement_first_10_clicks));   
        Games.Leaderboards.submitScoreImmediate(getApiClient(), "CgkI-    eXOwZsFEAIQBg", counter);
    }
}
}

private int getXp() {
SharedPreferences sharedPref =   PreferenceManager.getDefaultSharedPreferences(this);
return sharedPref.getInt("xp", 0);
}

private void saveXp(int xp) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("xp", xp);
editor.apply();
}

Here is the image of achievements inside my app 这是我的应用程序内成就的图片 成就形象

And here in the google play profile the xp doesn't add to the profile and also here the app's achievements section is not showing:- 而且在Google Play个人资料中,xp不会添加到个人资料中,并且在此应用的“成就”部分中不会显示:- 不包含XP添加和成就的游戏配置文件

Try to call getAchievementsIntent() as stated in the GPGS Displaying Achievements guide. 尝试按照GPGS显示成就指南中的说明调用getAchievementsIntent()。 That's the Android guide written by Google. 那是Google编写的Android指南。

startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
REQUEST_ACHIEVEMENTS);

Also try to check if this SO thread might be of help. 另外,请尝试检查此SO线程是否有帮助。

In the Google Play Games Github sample , it is invoked like this: Google Play游戏Github示例中 ,它的调用方式如下:

public void onShowAchievementsRequested() {
        if (isSignedIn()) {
            startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
                    RC_UNUSED);
        } else {
            BaseGameUtils.makeSimpleDialog(this, getString(R.string.achievements_not_available)).show();
        }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM