5
關於以循環J AndroidAsyncHttp examples我做一個GET請求是這樣的:循環J AndroidAsyncHttp和請求中的Cookie
final TextView text = (TextView) findViewById(R.id.textView);
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://example.com/mypage/", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
text.append(response);
}
});
我還加餅乾:
PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
client.setCookieStore(myCookieStore);
BasicClientCookie newCookie = new BasicClientCookie("id", 17882);
myCookieStore.addCookie(newCookie);
但是當一個GET請求,我怎麼能發送我的cookie在請求對象內?
關於到documentation客戶有以下方法簽名:
void get(Context context, String url, AsyncHttpResponseHandler responseHandler)
void get(Context context, String url, Header[] headers, RequestParams params, AsyncHttpResponseHandler responseHandler)
void get(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler)
void get(String url, AsyncHttpResponseHandler responseHandler)
void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler)
我會很高興,如果你可以給發送GET請求中持久Cookie的例子。
要添加餅乾已經在設置client.setCookieStore(myCookieStore)。只要確保在client.get()之前添加它們 – robotoaster