Skip to content
[WIP] A lightweight wrapper for connecting Android apps to Xively
Latest commit 190f976 Jul 2, 2013 Sam Mulube Merge pull request #5 from ericwaynedavis/master
Added support in HttpTask for writing Request body when HTTP method is PUT or POST

Xively Android library (BETA)

Please note that this library is still in beta.


This is an Android remote (AIDL) service for accessing Xively API asynchronously.

The implementation can be found under service subdirectory.

An example of the consumer of this service can be found under demo subdirectory.

It uses Android's URLConnection for handling HTTP requests and have no external dependencies.

It is deliberately designed to be very lightweight. For a fully featured HTTP client library, check out our Java library.

It currently supports API9 (Gingerbread) to API17 (Jelly Bean).


This library is Open Source, under the BSD 3-Clause.

Copyright © 2003-2013 LogMeIn, Inc. All rights reserved.

See for full text of the license.

Xively Credentials

You will need to set your API key and feed ID in these files:

  • test/src/com/xively/android/service/test/
  • demo/src/com/xively/android/consumer/

Configuring Android Service Consumer

The consumer of this service will be able to access Xively API via all methods defined in the IHttpService.aidl.

As seen from the demo project, the following files must be present in the consumer as per AIDL service specified by Android:

The name of the intent this service listens to is, as per the AndroidManifest.xml:

    <service android:name="" >
            <action android:name="" />

Multiple client apps can connect to this service if the include the above snippet on AndroidManifest.xml.

HTTP Service

RESTful requests to Xively API are managed by HttpService when invoked by an intent.

The service uses AsyncTask to make the request.

The response is expected to return from AsyncTask within the time as specified in HttpService.DEFAULT_TIMEOUT.

An exception will be thrown otherwise.

Exception Hierarchy

All exception thrown out of this library is RemoteException, as prescribed by AIDL specification.

For compatibility with Android version before API15, any caught exception in this service will be returned as a response with its status that represents an exception condition (HTTPService.HTTP_SERVICE_ERROR).

Data Formats

The response from the service can be retrieved as string:


which the client can then easily turned into a JsonObject by:

new JSONObject(response.getContent()) alpha

Something went wrong with that request. Please try again.