Android - Play a sound on achievement unlocked

╄→尐↘猪︶ㄣ 提交于 2019-12-03 09:15:44

Use the following code:

Games.Achievements.incrementImmediate(GoogleApiClient apiClient, String id, int numSteps).setResultCallback(new  ResultCallback<Achievements.UpdateAchievementResult>() {

            @Override
            public void onResult(UpdateAchievementResult result) {
                if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCKED) {
                    // play your sound. achievement was unlocked
                }
            }

        });

This will increment your achievement by the amount of steps you want, and when it is done, it will return some of these codes. If the code is GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCKED, then it means that increment unlocked the achievement and you can play your sound.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!