android - Google Play Achievement offline unlock and sync -


the google play documentation states:

an achievement can unlocked offline. when game comes online, syncs google play games services update achievement's unlocked state.

i tried unlocking achievement offline using:

games.achievements.unlock(mgoogleapiclient, achievementid); 

however, received following error:

java.lang.illegalstateexception: googleapiclient not connected yet. @ com.google.android.gms.internal.jx.a(unknown source) @ com.google.android.gms.common.api.c.b(unknown source) @ com.google.android.gms.games.internal.api.achievementsimpl.unlock(unknown source)

to prevent this, wrapped unlock statement check connection:

if (mgoogleapiclient.isconnected()) {         games.achievements.unlock(mgoogleapiclient, achievementid); } 

which solution used in example provided google play games:

 if (mgoogleapiclient.isconnected()) {       // unlock "trivial victory" achievement.       games.achievements.unlock(mgoogleapiclient,           getstring(r.string.achievement_trivial_victory));  } 

this solves error issue. however, not know how ensures achievement unlocked offline , synced when device goes online, assured in documentation quoted above. seems me unlock event ignored because mgoogleapiclient.isconnected() returns false when offline , there no way google play games know achievement unlocked offline once goes online since no information unlock event stored offline. (there no "else" block statement after "if" block statement, in offline achievement unlock handled)

am missing something? developer's responsibility store information achievement unlock when device offline , tell google play unlock achievement when device goes online?

the missing link can call mgoogleapiclient.connect() while offline - google play games will connect when offline, allowing call unlock() , other apis.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -