我想在游戏中显示一个按钮的总数增加的按钮。
theButton.setText(Integer.toString(game.appObj.firedIncrements(achString)));
以下函数成功返回值。
//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;
}
但它需要一个等待状态。 没有这种等待状态,我可以这样做吗? 更具体地说,我需要直接从apiClient对象访问“Achievement details”。 我是否可以将它们本地存储在单独的数据表或首选项中。?
提前致谢。