When created by the no argument constructor, a Handler runs on the
thread it is created on. You often see a Handler created on the main
thread intentionally, like in Mark's example above, so that a second
thread can send messages to it that will be acted on in the main
thread. This is needed because the Android UI Toolkit isn't thread
safe; it needs to be called from the main thread. The Handler in that
case is just used for UI updates, not for the work that should be done
in the other thread.

You can use a Handler for doing work in another thread, however.
There's an example of that in the documentation here:
http://developer.android.com/intl/de/reference/android/os/Looper.html

There are also some alternatives to that example explored here:
http://stackoverflow.com/questions/2187464/how-do-i-ensure-another-threads-handler-is-not-null-before-calling-it

On Mar 17, 6:03 am, Nithin <[email protected]> wrote:
> Hi,
>
> For showing loading screen, in the activity's main thread, I draw
> loading screen and created a handler for doing other extensive
> operations like database creations, parsing etc.
>
> But unfortunate;y, for me, all is executing in main thread only. Seems
> like Handler is not working as a seperate Thread. Any idea please..
>
> Nithin

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