pats pats - 7 months ago 61
Android Question

Increment achievement by achievement in android

My scenario : Lets say I have 3 achievements. I increment 1-achievement, when that is complete I want to increment 2-achievement and so on.

1) How do I switch between achievements and continue increments

2) is there a way to get which achievement I have to increment

3) Is there a way to change the look and feel of 'Games.Achievements.getAchievementsIntent' view?

4) If I want to enable in-app purchases after particular achievement how do I do it?



First Load achievements using
Games.Achievements.load (see Google Play Game Services get achievements list)

Second, loop through all achievements and see all incremental achievements and highest unlocked achievement. Then decide which incremental achievement (achivementId) to increment next.

Finally, use this code to reload achievement when one has been unlocked.

Games.Achievements.incrementImmediate(mGoogleApiClient, achivementId, 1)
                .setResultCallback(new ResultCallback<Achievements.UpdateAchievementResult>() {

                    public void onResult(Achievements.UpdateAchievementResult result) {
                        switch (result.getStatus().getStatusCode()) {
                            case GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCKED:
                          loadAchievements(); // load achivments and decide which one to increment next
                            case GamesStatusCodes.STATUS_ACHIEVEMENT_UNKNOWN:
                                // the achievement failed to update because could not find the achievement to update.
                            case GamesStatusCodes.STATUS_ACHIEVEMENT_NOT_INCREMENTAL:
                                // achievement failed to increment since it is not an incremental achievement.
                            case GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCK_FAILURE:
                                // the call to unlock achievement failed.