I want to show a button in my game with the Totalnumber of increments.
theButton.setText(Integer.toString(game.appObj.firedIncrements(achString)));
Following function returns the value succesfully.
//returns -1 or the number of steps;
public int firedIncrements(String achStringId) {
boolean fullLoad = false; // set to 'true' to reload all achievements (ignoring cache)
long waitTime = 20; // seconds to wait for achievements to load before timing out
// load achievements
int steps=-1;
PendingResult p = Games.Achievements.load( mGoogleApiClient, fullLoad );
Achievements.LoadAchievementsResult r = (Achievements.LoadAchievementsResult)p.await( waitTime, TimeUnit.SECONDS );
int status = r.getStatus().getStatusCode();
if ( status != GamesStatusCodes.STATUS_OK ) {
r.release();
return -1; // Error Occurred
}
// process the loaded achievements
AchievementBuffer buf = r.getAchievements();
int bufSize = buf.getCount();
for ( int i = 0; i < bufSize; i++ ) {
Achievement ach = buf.get( i );
// here you now have access to the achievement's data
if(achStringId==ach.getAchievementId())
{
steps = ach.getCurrentSteps();
}
//String id = ach.getAchievementId(); // the achievement ID string
steps = ach.getCurrentSteps(); // current incremental steps
}
buf.release();
r.release();
return steps;
}
But it needs a wait state. Can I do this without this wait state. To be more specific, i need to access the "Achievement details" from the apiClient object directly. Is it possible for me without storing them locally in seperate data tables or preferences.?
Thanks In Advance.