On 8 June 2010 17:52, Mark Murphy <[email protected]> wrote: > Andrew Brampton wrote: >> 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. > > The ContentObserver *is* your callback. You call > registerContentObserver() to say that you want to find out about certain > changes to the content, supplying a ContentObserver. That observer will > be called with onChange() when such a change occurs. >
On, so you call query() on a ContentProvider, which returns a empty Cursor, call registerContentObserver on it, then when the Cursor eventually gets the data your call back is called and you begin to use the Cursor. That makes sense. > > I haven't watched the presentation yet but I did read through the > slides. Off the cuff, the architecture presented there will probably > work well for something that is pretty truly RESTful, where the REST API > specifically is designed for inserting, updating, and deleting data. So, > for example, I can easily see the Twitter API fitting their proposed > architecture, at least for the timeline, but perhaps only for read > operations. I watched that presentation (and then many others) after reading your suggestion on your blog. BTW Thanks for your blog, help and book (even though admittedly I've not looked at your book). > > I'll have to experiment with their structure sometime and see if I can > create some reusable bits to reduce the complexity. Based on the slides, > this doesn't feel terribly easy for a developer to implement. > I was missing this Cursor registerContentObserver method, but I feel I can implement this myself and put it on github. If you want I can email you when I'm done. thanks Andrew -- 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

