On Mon, Oct 22, 2012 at 4:25 PM, ncdroid <jbla...@gmail.com> wrote:
> Thanks a lot for your feedback Mark.  Do you have a rule of thumb you apply
> to decide on AsyncTasks vs Loaders?  For example, if you expect something to
> take less than x mins, use AsyncTask, otherwise use a Loader?

CursorLoader and my loaders *use* AsyncTask under the covers. Hence,
time ("take less than x mins") is not a particularly useful metric
here -- the behavior using Loaders or using AsyncTask directly should
be roughly equivalent.

If you like the Loader framework, use it, particularly if you are also
using a ContentProvider.

If you do not like the Loader framework, don't use it. Unlike, say,
trying to avoid EditText, the use of Loaders is purely optional. In
particular:

-- you can't use Loaders on API Level 10 and below unless you are also
inheriting from FragmentActivity

-- you can only use Loaders from an Activity, not a Service, at least at present

In those cases, your hands are tied: you have to avoid Loaders.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.2 Available!

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