Saturday, April 13, 2013

[android help] Why use HandlerThread in Android

Why use HandlerThread in Android - Stack Overflow




















In android , Handler can be used to post / handle message, if I don't use a HandlerThread (pass its Looper to Handler), does that mean in this case Handler use MainThread (UI Thread) 's Looper ?


What result will get if Handler uses MainThread's Looper ? May cause mainThread blocked ?


























As Doc says :



Handy class for starting a new thread that has a looper.
The looper can then be used to create handler classes.
Note that start() must still be called.



HanderThread class inherits from the Thread class, which encapsulates the Looper object, so that we do not care The Looper open and release details. Like in case of normal thread we need to use Looper.prepare() and Looper.loop() to convert it as a LooperThread.























default







.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...