-
Notifications
You must be signed in to change notification settings - Fork 6
Home
SIRI REST Client UI is a sample user interface for an Android app that uses the SiriRestClient reference implementation Android library for interacting with the RESTful SIRI (Service Interface for Real Time Information) interface for real-time transit data, such as that currently being used by the [MTA Bus Time API] (http://bustime.mta.info/wiki/Developers/SIRIIntro).
SIRI is a public transportation standard developed by the European standards organization CEN. More information about SIRI can be found at the main SIRI website.
The purpose of this project is to stimulate innovation in mobile apps for the SIRI real-time transit API by providing an easy-to-use Android library that makes interacting with the API simple for app developers, thus lowering the learning curve for developing new real-time transit apps. This user-interface project illustrates how to use the SiriRestClient library in an Android app.
All SIRI REST Client source code is licensed under Apache 2.0.
This project was created in Eclipse using the Android SDK and Android Plugin for Eclipse. Libraries and dependencies are managed using [Maven Plugin for Eclipse] (http://eclipse.org/m2e/) (with an exception for ActionBarSherlock, as discussed below). After you've installed the above tools, note that you'll also need to install the m2e Android Maven plugin in Eclipse.
To get started with this project, use a Git client to clone this repository to your local computer. Then, in Eclipse do "File->Import->Maven->Existing Maven Projects", and point to the directory where you cloned the repo.
Next, you'll need to resolve a dependency on ActionBarSherlock, which is discussed in the next section below.
We use ABS to add support for the Android ActionBar to pre-Android 3.0 devices. ABS dependencies are not managed through Maven due to compatibility issues with Maven, Eclipse, and Android. We include the source for ABS in a subdirectory of this project (SiriRestClientUI\ActionBarSherlock), so if you cloned the main SiriRestClient you already have this code as well.
You just need to import the ActionBarSherlock project into Eclipse as an existing Android project (File->Import->Android->Existing Android Code Into Workspace) for SiriRestClientUI to see it.
SiriRestClient has dependencies on Jackson for parsing JSON and XML, which are managed via Maven. No configuration should be required for these dependencies to build with the SiriRestClient.
Please see the Parsing JSON and XML on Android wiki page for a full description of the use of Jackson with Android.
The SiriRestClient library implements the actual code that interfaces with the SIRI API. This dependency is managed via Maven, so no action is required on your part.
After you've completed the above steps, clean and build both projects (ActionBarSherlock and SiriRestClientUI, in that order). If you have any problems, try cleaning both projects, and restarting Eclipse, then building the ABS project, then the SiriRestClientUI project.
NOTE: If you have both the SiriRestClient library project and this project (SiriRestClientUI) open in Eclipse, you need to right click on the SiriRestClientUI project and go to "Properties -> Maven" and uncheck "Resolve dependencies from Workspace projects". See this post for details. Otherwise, you may get the error java.lang.NoClassDefFoundError: edu.usf.cutr.siri.android.client.config.SiriJacksonConfig
when you try to run SiriRestClientUI on a device. When trying to build SiriRestClientUI, if you get a message that Maven can't find the SiriRestClient maven artifact, trying closing the SiriRestClient library project, then building the SiriRestClientUI.
Also, be sure you're compiling both projects (ABS and SiriRestClientUI) under JDK 1.6. You may get @Override annotation errors
if you're compiling under JDK 1.5 or 1.7. See this post for instructions.
Note you'll need to provide a developer API key for a request to a server to actually return a reply. Please see the below section "Adding your own developer key for SIRI REST API servers" for instructions to add your key to the project.
Since the MTA BusTime API requires a [developer key] (http://bustime.mta.info/wiki/Developers/Index) to submit requests, you need to add your own developer key. When you compile and execute the app, your key will automatically be pulled from this file and populated in the key field.
First, open the plain text file in the raw
folder named devkey.txt
. Then, replace the entire string <Add your developer API key here>
with your developer key WITHOUT any whitespace or other characters.
As a result of the above steps, you should have a plain text file containing your developer key at /res/raw/devkey.txt
.
We've developed several tutorials based on what we've learned implementing the SiriRestClient Android library that this sample app uses, especially in the area of JSON and XML parsing on Android:
- Parsing JSON and XML on Android - Discusses how to use Jackson data binding to parse JSON and XML data in an Android app
- Modifying XML libraries for Android - Discusses the challenges of using XML parsing libraries on Android and how to overcome them
- Optimizations and Performance Benchmarks - We've outlined a few steps you can take to enhance the performance of parsing JSON or XML, including test results demonstrating the benefits on real devices! These optimizations are also built into the SiriRestClient library so you can start using them in your own app!