Proper Android REST client [closed]
Asked Answered
C

3

12

I made my own REST client library for an Android application, but after watching the Google I/O presentation on the subject I realized I had it all wrong (precisely what they show slide 9).

Now I am looking to do it again the right way, but I'm wondering if there isn't a library that could save me the trouble. We use Jersey on the server side.

I've looked at different solutions : CRest and Resty, but what I'd like to find an Android solution so I don't have to implement the ContentProvider stuff myself, and android-jbridge, but it doesn't look very active.

At this point I'm considering using RestTemplate (from Spring Android) and writing the stuff around it myself, but that'll take some time.

Any better alternative?

Cuthburt answered 3/8, 2011 at 17:28 Comment(4)
I've recently tried running jersey client on android platform without any major issues (actually it ran fine out of the box). So.. why are you not using what is already available?Estonian
Pavel - I (and many others) are getting a NPE in javax.ws.rs.core.MediaType.valueOf(MediaType.java:119) - what version of jersey did you use? Could you comment/answer this quesion: https://mcmap.net/q/1010239/-jersey-client-api-problemTomtit
hi pavel, i am having the exact same problem as kevin describes above -- could you please help us get around it?Amphibole
I'd really like to know what Pavel did to get that working, because I have also tried. It should actually be possible with a little mix&match hacking to get a properly running library. Anyone interested in putting some hours in?Dayton
K
11

"Developing Android REST client applications" by Virgil Dobjanschi led to much discussion, since no source code was presented during the session or was provided afterwards.

The only reference implementation I know (please comment if you know more) is available at Datadroid (the Google IO session is mentioned under /presentation). It is a library which you can use in your own application.

Update
There are other libraries available. I do not know how they confirm to Dobjanschis patterns, but I would like to list them for your reference (text is taken from the homepage of the library):

  • RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.

  • RESTDroid (currently alpha) provides a way to handle calls to REST web-services. It contains only the fundamental logic to handle these requests, extension is possible with modules (some are provided).

Kianakiang answered 1/1, 2012 at 16:33 Comment(4)
Perfect. Source here: github.com/foxykeep/datadroidCuthburt
As far as I can tell, Datadroid doesn't quite use Dobjanschi's pattern. That is, instead of ContentProvider methods triggering network operations behind the scenes, you explicitly start the network operation yourself and wait for the result from the network. The SQLite database isn't really necessary in the way that the sample app works. (I could be wrong about this; the code is insanely complicated for such a simple task.)Eyestrain
For information, the version 2 of DataDroid was released during the Christmas break. It simplifies the code you have to write and add more features for the webservice managements. @Eyestrain : DataDroid is using pattern A from Dobjanchi presentation. the one you are talking about is pattern B :)Blastocoel
This might be very helpful for people learning Android REST client implementation. Dobjanschi's presentation transcribed into a PDF: drive.google.com/file/d/0B2dn_3573C3RdlVpU2JBWXdSb3c/…Corposant
U
1

Another great library, sort of similar to RoboSpice, is Mechanoid Ops. It follows the pattern introduced / described by Virgil at IO 2010. Mechanoid also provides additional features that can come in handy such as SQLite database management.

see more here http://robotoworks.com/mechanoid/doc/index.html

Uncomfortable answered 24/4, 2013 at 15:8 Comment(0)
D
1

It is apparent from this blog post that the Jersey client supports Android from version 2.16.

Author quotes:

From Jersey version 2.16, it should be possible to use Jersey Client on Android.

However, I see there is a bug which is still unresolved (as of Feb 2015).

If your server is using the jersey RESTful implementation, the best choice is to use jersey client. If you're searching for Android REST client, you should try the jersey client version 2.16 (or onwards)

Descant answered 10/2, 2015 at 18:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.