Your point that they are 'orthogonal' is a surprise, and could use more elaboration. After all: from the Javadoc on AsyncTask, it sounds like the whole purpose of it is for one purpose only: to set up easy communications between an Activity (the normal owner of the UI main thread) and a worker thread. Nothing about Services, which often have no UI at all. So why would anyone use it with a Service in the first place? Or are you proposing using it only for Services that have already been created on the main thread, and using AsyncTask to immediately switch to the newly created background thread to do the bulk of the work of the Service?
And yes, IntentService is very useful. I am surprised that it doesn't get more attention in either that online documentation or the beginner's books for Android. It seems to me that many of the examples using Looper/Handler or AsyncTask could be done more simply with IntentService. On Oct 2, 2: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 For more options, visit this group at http://groups.google.com/group/android-developers?hl=en