Hi,
i am also trying to build an Rest-Client on Android and i also watched
the videos. So my solution for now is that i have a class wich has
very abstract methods like getUser(name) or addUser(user). The
Activity Only works with this class an gets Cursors from it. And this
Class once uses a ContentProvider to query/update the data in a local
Database but also starts a Service wich does the REST-Calls in a
worker Thread and parses the XML and updates the ContentProvider if
necassary(new Data). The ContentProvider calls notifyChange so that
the List in the Activity automatically changes its Data when the
service updated the localDatabase.
What do you think of that. Do you think it's a good solution?

Greetings,
Franky

On 8 Jun., 17:35, Andrew Brampton <[email protected]> wrote:
> I've watched many of the Google IO talks and one that I'm trying to
> reproduce is "Developing AndroidRESTclient applications"[1]. In this
> talk Virgil suggests you should not execute your RESTful queries
> inside a Thread/AsyncTask spawned from your Activity (which I had been
> doing), instead you should use a more complex architecture that uses a
> combination of a ContentProvider and a Service.
>
> From what I understood the reason for this design was so your data was
> more persistent between app restarts, and so your queries don't
> disappear if your Activity starts/stops (e.g on a screen rotation). I
> buy into both those reasons hence I'm trying to implement this.
>
> On the slides[2] page 45 We have an Activity calling a
> ContentProvider. Now the ContentProvider checks its local database, if
> the content is not there it sends an Intent to a service which fetches
> the content, inserts it into the ContentProvider, then the
> ContentProvider calls back to the Activity (with a ContentObserver)
> and the Activity can carry on. The question I have is how is this
> callback setup. The ContentProvider exposes simple methods, query,
> insert, update, delete which don't seem easy to adapt to a callback
> interface.
>
> It could be implemented by a Cursor which is designed to block, but
> that could be problematic as you don't' want to block your UI Thread.
> I'd appreciate if anyone could make this clearer to me, or show me
> some code. I'm hoping the Twitter app will be open sourced soon which
> apparently uses this architecture.
>
> thanks
> Andrew
>
> [1]http://code.google.com/events/io/2010/sessions/developing-RESTful-and...
> [2]http://dl.google.com/googleio/2010/android-developing-RESTful-android...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to