I'm not sure I agree with your comment that it is the wrong question. In
fact your explanation of how a majority of the cases a Service runs in the
same process is precisely why most people will consider these as
alternatives. I was trying to point out to the OP that if the OP ever wanted
to create something that lived independent of the UI and/or was planned to
be used by more than one activity independently developed/distributed, a
service would be a better choice...

IMHO the AsyncTask is notoriously poorly documented. It has some really
strange interactions with the Activity lifecycle... As some one pointed out
the IntentService is probably a better choice in many cases. Which again
brings to question the orthogonality of AsyncTask & Service...

On Sat, Oct 2, 2010 at 5:09 AM, Dianne Hackborn <hack...@android.com> wrote:

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