android - Listener for Leaderboard in Google game services -
i have setup leaderboard using google game services. using following statement submitting statistics after finishing game.
games.leaderboards.submitscore(mhelper.getapiclient(),leaderboardidforhits, totalchancetaken);
question :
there may situation there not internet services or failure during execution of above submit statement. on successful submit of statistics need show toast "statistics updated". know if there listener method this.
define class:
class myleaderboardsubmitscorecallback implements resultcallback<submitscoreresult> { @override public void onresult(submitscoreresult res) { if (res.getstatus().getstatuscode() == 0) { // data sent server. // display toast. } } }
then submit score this:
games.leaderboards.submitscoreimmediate(mhelper.getapiclient(),leaderboardidforhits, totalchancetaken).setresultcallback(new myleaderboardsubmitscorecallback());
so know when submit score, resultcallback
set, delivered when leaderboard score has been submitted. , if has been delivered server, display toast.
Comments
Post a Comment