![](/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.