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

前端 未结 2 1416
北荒
北荒 2021-01-27 06:14

I\'ve got a code with an ASyncTask and the problem is that when I execute it several times it crashes with this exception: RuntimeException: Only one Looper may be created per t

相关标签:
2条回答
  • 2021-01-27 06:59

    As the stack trace tells you, your problem originates from line 29 of Parser.java, in the Parser initializers. You will note that this is not the source code you included here, which is for LoadNews.

    Based on the preceding line of the stack trace, either:

    • Parser inherits from Activity

    • Parser is trying to instantiate an Activity

    Neither of those is possible.

    0 讨论(0)
  • 2021-01-27 07:07

    Maybe instantiate Parser outside LoadNews class and pass reference to it?

    0 讨论(0)
提交回复
热议问题