Bob Kerns wrote:
> * Create your Handler in the context of whatever you want to associate
> with handling it. For example, if you're updating a view in an
> activity, create it in the onCreate() method for the view.
> * Save your handler in an instance variable in that context. In other
> words, the Handler is owned by the context in which it runs, not the
> context in which messages are posted.
> * When you run some code in some other context that wants to post back
> -- pass it the Handler, so it can do so. (Often this will be from code
> from the same class -- you can just refer to the instance variable).

Excellent advice!

(though, a nit: in your first bullet, perhaps you mean onCreate() for
the activity, since there is no onCreate() for View)

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

Android Training in US: 14-18 June 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 [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