天天看点

Android在子线程里使用Toast报错Can't toast on a thread that has not called Looper.prepare()

实际上这个是在子线程中输出的,在logcat里查看有如下报错java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()。

解决办法为先调用​

​Looper.prepare();​

​​再调用​

​Toast.makeText().show();​

​​最后再调用​

​Looper.loop();​