我尝试将 AsyncHttpResponseHandler 的响应字符串存储在这样的类变量中:
public boolean isLatestVersion = true;
private void requestServerVersionFile() {
AsyncHttpClient client = new AsyncHttpClient();
client.get(appVersionCheckUrl, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String appVersionCodeServer) {
Log.e(LOG_TAG, appVersionCheckUrl + " = " + appVersionCodeServer);
int iResponse = Integer.parseInt(appVersionCodeServer.trim());
if(iResponse > appVersionCode)
{
isLatestVersion = false; //<<< tried this. and self. before
}
}
});
}
...但isLatestVersion 保持真实。覆盖此变量的正确/最聪明的方法是什么?