IdleSun's Weblog

December 12, 2010

Android Handler and Message Tutorial

Filed under: Android,Java — idlesun @ 1:44 am

 

This post has been moved to my new blog.

 

About these ads

9 Comments »

  1. Great tutorial! How do you catch an event from a non activity thread and send a message to the main activity ui thread without causing an ANR?

    Comment by Jase — August 17, 2011 @ 11:35 pm | Reply

    • You need to create a handler on the main thread where the handlers on other threads can send messages for UI updates. This restriction or rule applied even to using a Toast from a service. So the rule of thumb to keep in mind is that any UI update has to be done in the main thread of an application. And all the activities and services uses the same main thread as long as they are running in the same process.

      Comment by idlesun — August 18, 2011 @ 4:24 am | Reply

  2. The source code zip file appears to have a file name that ends with .gif. I right-clicked on the download link and did a “save-as” and changed the extension to zip and it works fine.

    Comment by williamkida — February 13, 2012 @ 8:40 pm | Reply

  3. how to find out the flow of handler

    Comment by irfan khan — June 7, 2012 @ 6:05 am | Reply

  4. Is your handler static for any particular reason?

    Comment by anonymous — June 30, 2012 @ 10:25 pm | Reply

    • No specific reason. I guess you can remove it.

      Comment by idlesun — July 2, 2012 @ 7:15 am | Reply

  5. Nice Thread Tutorial, i am new in android , its help me a lot …

    I have got some good links

    here at androidexample.com

    Thread_With_Handlers

    Comment by Android Example — February 4, 2013 @ 8:05 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: