Android handler 报错处理Can't create handler inside thread that has not called Looper.prepare()(示例代码

Posted 笨蛋敏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android handler 报错处理Can't create handler inside thread that has not called Looper.prepare()(示例代码相关的知识,希望对你有一定的参考价值。

解决方法,在ui线程里面创建handler

m_MainActivity.runOnUiThread(new Runnable(){

            @Override
            public void run() {
                // TODO Auto-generated method stub
                GameBoxUtil.startPay(m_MainActivity,String.valueOf(amount), productName, payCode,orderId,payHandler);
            }}); 

 

以上是关于Android handler 报错处理Can't create handler inside thread that has not called Looper.prepare()(示例代码的主要内容,如果未能解决你的问题,请参考以下文章

使用 Android Looper 仍然抛出“Can't create handler inside...”

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

在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()(示例代码

转 在子线程中new Handler报错--Can't create handler inside thread that has not called Looper.prepare()(示例

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

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