gpt4 book ai didi

android - 通过android中的成就来增加成就

转载 作者:行者123 更新时间:2023-11-30 02:10:37 24 4
gpt4 key购买 nike

我的场景:假设我有 3 个成就。我增加 1-achievement,完成后我想增加 2-achievement,依此类推。

1) 如何在成就和继续增量之间切换

2) 有没有办法获得我必须增加的成就

3) 有没有办法改变“Games.Achievements.getAchievementsIntent” View 的外观?

4) 如果我想在特定成就后启用应用内购买,我该怎么做?

谢谢

最佳答案

要完成所有这些,您必须创建一个函数,它接受一个参数,如下所示:

 public boolean unlockAchievement(int whichAchievement)

{
switch(whichAchievement)
{
case 1:

achievementId = mainActivity.getString(R.string.achievement_id_1);
achievementCause = mainActivity
.getString(R.string.achievement_cause_1);
break;
case 2:
achievementId = mainActivity.getString(R.string.achievement_id_2);
achievementCause = mainActivity
.getString(R.string.achievement_cause_2);
//Enable inapp purchase here
break;
}

AchievementsClient acClient = mainActivity.agsClient
.getAchievementsClient();
AGResponseHandle<UpdateProgressResponse> handle = acClient
.updateProgress(achievementId, 100.0f);

// Optional callback to receive notification of success/failure.
handle.setCallback(new AGResponseCallback<UpdateProgressResponse>() {

@Override
public void onComplete(UpdateProgressResponse result) {
if (result.isError()) {
// Toast.makeText(mainActivity,
// "Something is wrong and achievement is not unlocked",
// Toast.LENGTH_LONG).show();
} else {
// Toast.makeText(mainActivity,
// "Achievement unlocked successfully",
// Toast.LENGTH_LONG).show();
}
}
});

每当您解锁成就时调用此函数。宾果!

关于android - 通过android中的成就来增加成就,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30159296/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com