stanlick wrote:
> Does Google offer formal training on Android?

Not that I am aware of. If they do, they sure keep quiet about it.

> I read, studied, and coded the background processing technique using
> the Handler callback and it seemed to work alright.  Lot's of
> boilerplate code and switches on arbitrary integers, but it worked and
> my UI was responsive.  A few days later I read a post from a Google
> Pro (thanks Dmitri) who discussed using AsynchTask instead because of
> its clarity and readability.  These both accomplish the same end goal
> -- avoiding the dreaded ANR!

Technologies evolve.

AsyncTask (note: there is no 'h' in the name) was not introduced until
Android 1.5, and I believe it originated with a sample app (Shelves)
that Romain Guy wrote early in 2009. Hence, patterns also evolve --
using AsyncTask as part of a pattern would have been impossible a year
ago, short of time travel.

> I have taught technology
> classes for several years and I realize that after careful review,
> most "authorities" are only a few days (or maybe weeks) smarter than
> you are on the subject.  Getting your education this way is risky
> business.

Welcome to the bleeding edge.

> P.S. What technique should be used to run processes in the background
> to avoid timing out your UI?
> 
> a) Handler
> b) new Thread()
> c) Service call
> d) AsynchTask
> e) it depends!

You write that list as if they are mutually exclusive. In some cases,
you'll use three of those simultaneously (e.g., forking a new Thread()
in a service that invokes a callback that uses a Handler to update a UI).

Personally, I've settled upon AsyncTask (in an activity or service) as
my weapon of choice for most cases ("it depends!"). IntentService also
works well for some situations, such as "cron job" style services
triggered by AlarmManager, as IntentService automatically arranges for
work to be done on an Android-managed background thread.

However, I'm one of those "authorities" that "are only a few days (or
maybe weeks) smarter than you are on the subject", and so reading the
preceding paragraphs was "risky business"...

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

Android Training in Germany, 18-22 January 2010: http://bignerdranch.com

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