|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.loopj.android.http.AsyncHttpClient
public class AsyncHttpClient
The AsyncHttpClient can be used to make asynchronous GET, POST, PUT and
DELETE HTTP requests in your Android applications. Requests can be made
with additional parameters by passing a RequestParams instance,
and responses can be handled by passing an anonymously overridden
AsyncHttpResponseHandler instance.
For example:
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println(response);
}
});
| Constructor Summary | |
|---|---|
AsyncHttpClient()
Creates a new AsyncHttpClient. |
|
| Method Summary | |
|---|---|
void |
cancelRequests(Context context,
boolean mayInterruptIfRunning)
Cancels any pending (or potentially active) requests associated with the passed Context. |
void |
delete(Context context,
String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP DELETE request. |
void |
delete(String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP DELETE request. |
void |
get(Context context,
String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP GET request without any parameters and track the Android Context which initiated the request. |
void |
get(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP GET request and track the Android Context which initiated the request. |
void |
get(String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP GET request, without any parameters. |
void |
get(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP GET request with parameters. |
HttpClient |
getHttpClient()
Get the underlying HttpClient instance. |
void |
post(Context context,
String url,
HttpEntity entity,
String contentType,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request. |
void |
post(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP POST request and track the Android Context which initiated the request. |
void |
post(String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP POST request, without any parameters. |
void |
post(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP POST request with parameters. |
void |
put(Context context,
String url,
HttpEntity entity,
String contentType,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP PUT request and track the Android Context which initiated the request. |
void |
put(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP PUT request and track the Android Context which initiated the request. |
void |
put(String url,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP PUT request, without any parameters. |
void |
put(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
Perform a HTTP PUT request with parameters. |
void |
setCookieStore(CookieStore cookieStore)
Sets an optional CookieStore to use when making requests |
void |
setSSLSocketFactory(SSLSocketFactory sslSocketFactory)
Sets the SSLSocketFactory to user when making requests. |
void |
setThreadPool(ThreadPoolExecutor threadPool)
Overrides the threadpool implementation used when queuing/pooling requests. |
void |
setUserAgent(String userAgent)
Sets the User-Agent header to be sent with each request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AsyncHttpClient()
| Method Detail |
|---|
public HttpClient getHttpClient()
public void setCookieStore(CookieStore cookieStore)
cookieStore - The CookieStore implementation to use, usually an instance of PersistentCookieStorepublic void setThreadPool(ThreadPoolExecutor threadPool)
threadPool - an instance of ThreadPoolExecutor to use for queuing/pooling requests.public void setUserAgent(String userAgent)
userAgent - the string to use in the User-Agent header.public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory)
sslSocketFactory - the socket factory to use for https requests.
public void cancelRequests(Context context,
boolean mayInterruptIfRunning)
Note: This will only affect requests which were created with a non-null android Context. This method is intended to be used in the onDestroy method of your android activities to destroy all requests which are no longer required.
context - the android Context instance associated to the request.mayInterruptIfRunning - specifies if active requests should be cancelled along with pending requests.
public void get(String url,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
public void get(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.params - additional GET parameters to send with the request.responseHandler - the response handler instance that should handle the response.
public void get(Context context,
String url,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
public void get(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.params - additional GET parameters to send with the request.responseHandler - the response handler instance that should handle the response.
public void post(String url,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
public void post(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.params - additional POST parameters or files to send with the request.responseHandler - the response handler instance that should handle the response.
public void post(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.params - additional POST parameters or files to send with the request.responseHandler - the response handler instance that should handle the response.
public void post(Context context,
String url,
HttpEntity entity,
String contentType,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.entity - a raw HttpEntity to send with the request, for example, use this to send string/json/xml payloads to a server by passing a StringEntity.contentType - the content type of the payload you are sending, for example application/json if sending a json payload.responseHandler - the response handler instance that should handle the response.
public void put(String url,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
public void put(String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.params - additional PUT parameters or files to send with the request.responseHandler - the response handler instance that should handle the response.
public void put(Context context,
String url,
RequestParams params,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.params - additional PUT parameters or files to send with the request.responseHandler - the response handler instance that should handle the response.
public void put(Context context,
String url,
HttpEntity entity,
String contentType,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.entity - a raw HttpEntity to send with the request, for example, use this to send string/json/xml payloads to a server by passing a StringEntity.contentType - the content type of the payload you are sending, for example application/json if sending a json payload.responseHandler - the response handler instance that should handle the response.
public void delete(String url,
AsyncHttpResponseHandler responseHandler)
url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
public void delete(Context context,
String url,
AsyncHttpResponseHandler responseHandler)
context - the Android Context which initiated the request.url - the URL to send the request to.responseHandler - the response handler instance that should handle the response.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||