• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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: 27590
88
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: 27590
88
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.
 
A feeble attempt to tell you about our stuff that makes us money
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic