我有以下代码使用REST服务来获取用户凭据。
public class Login extends FragmentActivity
{
public void invokeWS(RequestParams params){
final ResponseObj responseObj = new ResponseObj();
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://<ip>:<port>/RestService/login/dologin",
params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
responseObj.setResponse(response);
}
// When the response returned by REST has Http response code
// other than '200'
@SuppressWarnings("unused")
public void onFailure(int statusCode, Throwable error,
String content) {
responseObj.setContent(content);
responseObj.setStatusCode(statusCode);
}
}
);
}
// rest of the logic
}
然而,我得到了着名的&#34;不能引用封闭范围中定义的非最终局部变量&#34;在变量responseObj上。我的变量是最终的,因此应该是可访问的。我错过了什么?