On Fri, Oct 1, 2010 at 2:07 PM, Prakash Iyer <thei...@gmail.com> wrote:

> Service, OTOH, is designed to work in the background without requiring user
> interaction. Problem is that for your Activity to display the results it
> must somehow interact with your service. Ideally you will want to spawn the
> service off in a separate process and use either Intents or AIDL to
> communicate back progress to the Activity.
>

The vast majority of the time, there is no need to run the service in a
separate process and thus deal with all of the additional complexity of AIDL
and such.

As another poster mentioned, IntentService is very useful.

Also "AsyncTask vs. Service" is the wrong question.  These are almost
totally orthogonal to each other -- you very often may use an AsyncTask as
part of implementing a service for example.

And if your service is running in the same process as your activity, it is
very easy to just bind to it from the activity, call on to it to get its
current state, and supply a callback for when the state changes, just using
normal Java coding.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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