An asynchronous callback-based Http client for Android built on top of Apache’s
All requests are made outside of your app’s main UI thread, but any callback
logic will be executed on the same thread as the callback was created using
Android’s Handler message passing. You can also use it in Service or background thread,
library will automatically recognize in which context is ran.
Using upstream HttpClient of version 4.3.6 instead of Android provided DefaultHttpClient
Compatible with Android API 23 and higher
Make asynchronous HTTP requests, handle responses in anonymous callbacks
HTTP requests happen outside the UI thread
Requests use a threadpool to cap concurrent resource usage
GET/POST params builder (RequestParams)
Multipart file uploads with no additional third party libraries
Streamed JSON uploads with no additional libraries
Handling circular and relative redirects
Tiny size overhead to your application, only 90kb for everything
Automatic smart request retries optimized for spotty mobile connections
Automatic gzip response decoding support for super-fast requests
Binary protocol communication with BinaryHttpResponseHandler
Built-in response parsing into JSON with JsonHttpResponseHandler
Saving response directly into file with FileAsyncHttpResponseHandler
Persistent cookie store, saves cookies into your app’s SharedPreferences
Integration with Jackson JSON, Gson or other JSON (de)serializing libraries with BaseJsonHttpResponseHandler
Support for SAX parser with SaxAsyncHttpResponseHandler
Support for languages and content encodings, not just UTF-8
Persistent Cookie Storage with PersistentCookieStore
This library also includes a PersistentCookieStore which is an implementation
of the Apache HttpClient CookieStore interface that automatically saves
cookies to SharedPreferences storage on the Android device.
sessions, since the user will remain logged in even after closing and
re-opening your app.
First, create an instance of AsyncHttpClient:
Now set this client’s cookie store to be a new instance of
PersistentCookieStore, constructed with an activity or application context
(usually this will suffice):
Any cookies received from servers will now be stored in the persistent cookie
To add your own cookies to the store, simply construct a new cookie and
Some requests may need username/password credentials when dealing with API services that use HTTP Basic Access Authentication requests.
You can use the method setBasicAuth() to provide your credentials.
Set username/password for any host and realm for a particular request.
By default the Authentication Scope is for any host, port and realm.
You can also provide a more specific Authentication Scope (recommended)