Based on my experience with similar implementations, I would recommend this
approach.

In my case, I used a ContentProvider to accumulate data from an
IntentService. This allowed me to obtain data in the form of Cursors that
would automatically trigger view updates in response to change
notifications. The nice thing about this approach is that almost all the
plumbing is handled by the system components.

I think the best advice I can think of regarding when to use a Service for a
particular task is to ask the question: Is there any benefit to having the
system know about the task? If the answer is no, then there's probably
nothing to gain by using a Service.

Here the answer is clearly yes, because if the system doesn't know about
this sync, it's liable to kill your process at some point after the user has
navigated away from the app, still waiting for the sync to complete.

Tom.

On 2 October 2010 17:34, Bret Foreman <bret.fore...@gmail.com> wrote:

> The best IntentService pattern I use is handling online web services,
> which can take several seconds to respond. I launch IntentServices to
> get data from various web services, and the data is placed in an
> SQLite db. The IntentService broadcasts a message back to the UI
> activity when it's done and the UI picks up the data from SQLite. In
> this way, the UI can populate various Views with data as it comes in
> from various web services (and show a default message/image in the
> view while it waits). The whole process is fairly simple, very robust,
> and looks good to the user.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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

Reply via email to