RESTProvider handles all the HTTP querying and caching. Users can seamlessly interface with any Web Service API which provides JSON or XML as a response. To query a RESTProvider in an activity a user need only specify an endpoint and then query an APIs RESTful functions.
- Supports JSON & XML Web services
- Handles HTTP querying & caching
RESTProvider is an implementation of functionality commonly used when dealing with web services in Android.
public class TwitterFeedExample extends ListActivity {
@Override public void onCreate(Bundle b) {
super.onCreate(b);
CPAsyncHandler g = new CPAsyncHandler(getContentResolver());
g.startQuery(1, null, Uri.parse("content:https://novoda.rest.test.twitter"),
null, "q=?", new String[] { "droidcon" }, null);
}
private class CPAsyncHandler extends AsyncQueryHandler {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor c) {
super.onQueryComplete(token, cookie, c);
setListAdapter(new SimpleCursorAdapter(TwitterFeedExample.this,
android.R.layout.simple_list_item_2, c, new String[] {
"from_user", "text" }, new int[] {
android.R.id.text1, android.R.id.text2 }));
}
public CPAsyncHandler(ContentResolver cr) {
super(cr);
}
}
}
- GIT: git clone git:https://github.com/novoda/RESTProvider.git
- Archive: https://github.com/novoda/RESTProvider/archives/master
- JAR: https://github.com/novoda/RESTProvider/downloads
- Home: https://github.com/novoda/RESTProvider
The RESTProvider’s most recent version is only available in source but regular versions are available as jar files.
We recommend working from source as significant changes are still frequent at these early stages.
Download the latest source as an archive or checkout via git. The advantage of checking out via git is that updates can be quickly applied within your working environment using $git pull origin master. To checkout the latest source via git, within the directory you wish to download the project: git clone git:https://github.com/novoda/RESTProvider.git
In Eclipse:
File > New Android Project
Select Create project from existing source
For the location select: RESTProvider/RESTProvider
Dependant files needed on build path, add the following to RESTProvider/RESTProvider/lib
- Signpost-core-1.1.jar
- Signpost-commonsHTTP-1.1.jar
- Droidfu v1
- DOM4J
- Jackson-core-asl-1.4.1.jar
- Jackson-mapper-asl-1.4.1.jar
- Google Collections 1.0
Refresh the directories in eclipse (F5 with the project selected)
All jars under ‘libs’ need to be added to the build path.
You can add each dependancy by right clicking the jar files under this directory and selecting Build Path > Add to Build Path.
You can now depend on this project as a build dependancy to use the RESTProvider in your project.
Follow these steps in Eclipse:
File > New Android Project
Select Create project from existing source
For the location select: RESTProvider/RESTProviderTest
All of the libraries under the RESTprovider ‘libs’ directory need to be added to the build path.
You can add each library by right clicking the jar files under this directory and selecting Build Path > Add to Build Path.
Dependant files needed on build path as Android cannot src the dependencies from the other project, add the followingto RESTProvider/RESTProviderTest/lib
- Signpost-core-1.1.jar
- Signpost-commonsHTTP-1.1.jar
- Droidfu v1
- DOM4J
- Jackson-core-asl-1.4.1.jar
- Jackson-mapper-asl-1.4.1.jar
You then need to add the RESTProvider’s src as a dependency of this project by right clicking Build Path > Link Src then selecting the directory of the RESTProvider’s src on your disk.
Note: Intrumentations cannot be run if the RESTProvider is included as src in the Demo project
This is an experimental way of testing an android locally without deploying to the against an android emulated image using a n android.jar customly extended for testing. In order to provide a test framework, we use PowerMock as describe in the following page which I strongly recommend to follow and understand:
https://sites.google.com/site/androiddevtesting/
In Eclipse:
File > New Java Project
Select Create new project from existing source
For the location select: RESTProvider/RESTProviderLocalTest
Right click on Project dir
Build path > Configure Build Path
Add the RestProvider project as a dependency.
Dependant files needed on build path in the lib dir:
In order for your dependant project to deploy correctly you will need to export the RESTProvider into your dependant project
as a jar. To do this:
The RESTProvider project is for everyone to take advantage and will improve only with your feedback.
If you are using the RESTProvider or have issues then please let the community know.
This project is unsupported but contributors will try their best to reply to problems on mailing list.
https://groups.google.com/group/android-restprovider
Or you can raise issues on github.