• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread :Can't create handler inside thread that has not called Looper.prepare()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a beginner, and I'm trying to create a 2D game and I have issue that I don't understand and don't know how to solve.

I have an issue with a thread and the error I get is

Can't create handler inside thread that has not called Looper.prepare()

I saw some question anout this issue, but I couldn't figure out the way to solve it.

This is the code


 
Marshal
Posts: 28261
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sahar, welcome to the Ranch!

If I was the one who got that message "Can't create handler inside thread that has not called Looper.prepare()" then my first idea would be to have my thread call Looper.prepare(). Probably near the beginning, because "prepare" sounds like the sort of thing which should be done at the beginning. I'd suggest trying that.
 
Sahar Cohen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Hi Sahar, welcome to the Ranch!

If I was the one who got that message "Can't create handler inside thread that has not called Looper.prepare()" then my first idea would be to have my thread call Looper.prepare(). Probably near the beginning, because "prepare" sounds like the sort of thing which should be done at the beginning. I'd suggest trying that.



Hi Paul, Thanks for your response.
I tried at first to put Looper.prepare (): before while but it did not help
I think I need to use Thread and Handler with getMainLooper but I do not have any idea how to combine them together
You have an idea?
 
Paul Clapham
Marshal
Posts: 28261
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sahar Cohen wrote:You have an idea?



No, sorry, "did not help" doesn't spark any bright ideas in my head.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sahar Cohen,

If you TellTheDetails (that's link) of what happened when you tried to put Looper.prepare() before the while loop, you may get a better response.

I've moved this to the Android forum.
reply
    Bookmark Topic Watch Topic
  • New Topic