0

Android docs on Looper are not clear in stating whether we shall use Looper or not. I have seen many places saying not to use Looper with Handler, but to use AsyncTask or some similar non-main thread methodology.

So shall we ever use Looper or not?

If yes, when me have to use it (not must or should)? Only when passing UI update message from the thread to the main thread or there are some other cases as well?

sandalone
  • 41,141
  • 63
  • 222
  • 338
  • 1
    `some similar non-main thread methodology.` Which is the key to answer your question: too much work on your main thread may cause crashes, – Phantômaxx Jan 04 '16 at 14:55
  • That was my idea years ago when I started learning Android. But now, each time I am interviewed for a senior position, I am asked "do you use Looper, why and when". Obviously all seniors in those companies are using it... which is the reason I asked the question. – sandalone Jan 04 '16 at 15:14
  • 1
    then answer those seniors: `no i am always using a HandlerThread`, its docs say: `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.` – pskink Jan 04 '16 at 15:52

0 Answers0