AsyncHttpClient library
This is a lightweight asynchronous HTTP client powered by OkHttp but with a significantly simplified and easier to use API design.
The goal of this library is to have an API that clearly and cleanly supports the following features:
- Asynchronous network requests without any need for manual thread handling
- Response
onSuccesscallbacks run on the mainthread (by default) - Easy way to catch all errors and failures and handle them
- Easy pluggable Text, JSON, and Bitmap response handlers to parse the response
This client tries to follow a similar API inspired by this older now deprecated android-async-http library.
Setup
To use this library, add the following to your .gradle file:
dependencies {
implementation 'com.codepath.libraries:asynchttpclient:0.0.9'
}Basic usage
-
Make sure all network calls are using
https://instead ofhttp:// -
Verify that network access is allowed via the
<uses-permission>:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.codepath.example"> <uses-permission android:name="android.permission.INTERNET" />```
-
Add any networking calls by leveraging the
AsyncHttpClientAsyncHttpClient client = new AsyncHttpClient(); client.get("https://api.thecatapi.com/v1/images/search", new TextHttpResponseHandler() { @Override public void onSuccess(int statusCode, Headers headers, String response) { Log.d("DEBUG", response); } @Override public void onFailure(int statusCode, @Nullable Headers headers, String errorResponse, @Nullable Throwable throwable) { Log.d("DEBUG", errorResponse); } });
This example uses
TextHttpResponseHandlerwhich presents the response as raw text. We could use theJsonHttpResponseHandlerinstead to have the API response automatically parsed for us into JSON. See other example calls here.
For more detailed usages, check out the CodePath Async Http Client Guide.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
