> On Fri, May 1, 2009 at 8:07 PM, Mark Murphy <[email protected]>
> wrote:
>
>> It looks like you are trying to manually instantiate a Handler, or
>> possibly an Activity, in the background thread. If so, that is not the
>> proper way to use a Handler. This is one of the reasons I dislike
>> Handler, preferring runOnUiThread() (and hopefully the new AsyncTask).
>>
> Yes, it seems that the proper way is to instantiate the Handler when being
> on the UI thread.

>From what I can tell, this is done traditionally as an initializer in an
activity:

public class Foo extends Activity {
  Handler myHandler=new Handler() {
    // impl methods here
  };

  // rest of activity here
}

Though, as you note, specialty classes like AsyncTask may use Handler
somewhat differently.

> Thanks for the heads-up. I've never seen AsyncTask before and meanwhile it
> seems that it's an Android 1.5 feature.

Yes, that's new to 1.5.

> Mark, as always, you were very helpful. Thank you!

Happy to help!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



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

Reply via email to