Is it possible to use AsyncTask in a Service class ?

Posted by Spredzy on Stack Overflow See other posts from Stack Overflow or by Spredzy
Published on 2010-05-01T16:19:47Z Indexed on 2010/05/01 16:27 UTC
Read the original article Hit count: 280

Filed under:
|
|
|

Everything is in the title.

On the official documentations it is stated that Note that services, like other application objects, run in the main thread of their hosting process and AsyncTask only works if it is executed in the UIThread.

So is it possible to use AsyncTask in a Service class?

I am trying to do so but I'm always getting the same error

05-01 18:09:25.487: ERROR/JavaBinder(270): java.lang.ExceptionInInitializerError

...

05-01 18:09:25.487: ERROR/JavaBinder(270): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Am I doing something wrong or is this just impossible ?

© Stack Overflow or respective owner

Related posts about android

Related posts about thread