On Tue, Sep 27, 2011 at 2:52 PM, stanlick <[email protected]> wrote: > With respect to the one-and-done off-UI thread task, is there a best > usage pattern?
There are usage patterns. Best? That's tough to say. > IntentService dispenses with the > configuration changes but leaves you in a lurch when requiring a > response. Not really. Use a broadcast Intent, or a Messenger, or a PendingIntent, etc. The ordered broadcast pattern is particularly useful for cases where an IntentService is largely asynchronous from any activity: http://commonsware.com/blog/2010/08/11/activity-notification-ordered-broadcast.html https://github.com/commonsguy/cw-advandroid/tree/master/Broadcast/Ordered > I'm sure the other off-UI thread techniques bring their own > idiosyncrasies when the host Activity could die and be resurrected > while they are off working on behalf of the now deceased activity. My rough-cut rule of thumb at the moment is: use an IntentService if the work being done should still be done regardless of what's happening at the UI level. Use an AsyncTask if the results are inextricably tied to a logical activity (i.e., an activity instance and any related instances created due to configuration changes). -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- 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

