Fred Medlin

Hello, RestClient

RestClient is a new Android library project for consuming RESTful api resources. It’s inspired by the RestKit Project but for, you know, Android.

RestClient uses a Builder pattern for object creation that is simple and flexible. Object construction begins with specifying the endpoint of a service api url. There are additional methods for setting the resource, request operation, query parameters, http request parameters, etc.

The execute method starts the network connection with the api service. It runs in the background, so control will return immediately to the calling thread. A completion listener callback is invoked when the operation is complete. It runs in the UI thread, so it is safe to manipulate the UI in the callback methods.

There is a blocking synchronousExecute() method; handy for those times when you’re already running in the background and just want to make the api call in the same thread.

I’ve been gradually refining the library in several commercial projects. This is a new implementation however, replacing Apache Http classes with HttpURLConnection in order to take advantage of future http work from the Android team.

Documentation is non-existent right now, so your best bet is to refer to the Robolectric based tests.

The next task is to complete the port using HttpURLConnection and beef up the docs and examples. At that point, it should really be production ready. As I said, I’ve used an Apache based implementation in several apps already and it’s been pretty solid.