我尝试将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保持正确。 覆盖此变量的正确/最明智的方法是什么?