![](/img/trans.png)
[英]Getting HTTP response code using Android Asynchronous Http Client (Loopj)
[英]Associating responses with specific requests using Loopj Android Asynchronous Http Client
我正在使用Loopj Android异步HTTP客户端异步发送多个HTTP请求。
我按照建议使用静态AsyncHttpClient
,并发送多个HTTP帖子并在匿名类上接收响应。 问题是当请求返回时,我不知道如何将其绑定到原始请求。
例如,在缓存情况下,当我发送帖子并收到200 OK时,我需要能够知道该响应是针对哪个请求的,以便将其标记为成功发送。
尝试这个:
public class MyAsyncHttpResponseHandler extends AsyncHttpResponseHandler {
private String requestId;
public AsyncHttpResponseHandler(String requestId) {
this.requestId = requestId;
}
@Override
public void onSuccess(String arg0)
{
super.onSuccess(arg0);
// Use requestId here
}
}
发送请求:
client.get(url, new MyAsyncHttpResponseHandler(requestId))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.