View on GitHub

ion

Android Asynchronous Networking and Image Loading

Download this project as a .zip fileDownload this project as a tar.gz file

Android Asynchronous Networking and Image Loading

Download

Features

Samples

The included documented ion-sample project includes some samples that demo common Android network operations:

More Examples

Looking for more? Check out the examples below that demonstrate some other common scenarios. You can also take a look at 30+ ion unit tests in the ion-test.

Get JSON

Post JSON and read JSON

Post application/x-www-form-urlencoded and read a String

Post multipart/form-data and read JSON with an upload progress bar

Download a File with a progress bar

Setting Headers

Load an image into an ImageView

The Ion Image load API has the following features: Disk and memory caching Bitmaps are held via weak references so memory is managed very efficiently ListView Adapter recycling support Bitmap transformations via the .transform(Transform) Animate loading and loaded ImageView states DeepZoom for extremely large images

Futures

All operations return a custom Future that allows you to specify a callback that runs on completion.

Cancelling Requests

Futures can be cancelled by calling .cancel():

Blocking on Requests

Though you should try to use callbacks for handling requests whenever possible, blocking on requests is possible too. All Futures have a Future<T>.get() method that waits for the result of the request, by blocking if necessary.

Seamlessly use your own Java classes with Gson

Logging

Wondering why your app is slow? Ion lets you do both global and request level logging.

To enable it globally:

Or to enable it on just a single request:

Log entries will look like this:

Request Groups

By default, Ion automatically places all requests into a group with all the other requests created by that Activity or Service. Using the cancelAll(Activity) call, all requests still pending can be easily cancelled:

Ion also lets you tag your requests into groups to allow for easy cancellation of requests in that group later:

Proxy Servers (like Charles Proxy)

Proxy server settings can be enabled all Ion requests, or on a per request basis:

Using Charles Proxy on your desktop computer in conjunction with request proxying will prove invaluable for debugging!

Viewing Received Headers

Ion operations return a ResponseFuture, which grant access to response properties via the Response object. The Response object contains the headers, as well as the result:

Get Ion

Maven

Gradle

`

Local Checkout (with AndroidAsync dependency)

Jars are at ion/ion/bin/classes.jar AndroidAsync/AndroidAsync/bin/classes.jar

Hack in Eclipse

Import the project from AndroidAsync/AndroidAsync into your workspace Import all the ion projects (ion/ion, ion/ion-sample) into your workspace.

Projects using ion

There's hundreds of apps using ion. Feel free to contact me or submit a pull request to add yours to this list.