[android-developers] How to wait for Asynctask to return with data

2010-07-06 Thread Stephen Lebed
Hi,

I'm calling an AsyncTask in my UI thread from a button click.  The
AsyncTask is collecting data from the hardware sensors, and will store
the info into global variables that I'll perform work from.  I'd like
to know how to either wait for the AsyncTask to finish without locking
up the UI, or how to trigger an event when AsyncTask is finished.

Thanks,
Stephen

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


Re: [android-developers] How to wait for Asynctask to return with data

2010-07-06 Thread Mark Murphy
On Tue, Jul 6, 2010 at 12:57 PM, Stephen Lebed srle...@gmail.com wrote:
 I'm calling an AsyncTask in my UI thread from a button click.  The
 AsyncTask is collecting data from the hardware sensors, and will store
 the info into global variables that I'll perform work from.

global variables = ick.

 I'd like
 to know how to either wait for the AsyncTask to finish without locking
 up the UI, or how to trigger an event when AsyncTask is finished.

Override onPostExecute() in the AsyncTask and do your work there. In
fact, why not get rid of the global variables, hold onto the data in
the AsyncTask, and just apply them in onPostExecute()?

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

Android Development Wiki: http://wiki.andmob.org

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