原文:在子線程中new Handler報錯--Can't create handler inside thread that has not called Looper.prepare()

在子線程中new一個Handler為什么會報以下錯誤 java.lang.RuntimeException: Can tcreatehandlerinsidethreadthathasnotcalledLooper.prepare 這是因為Handler對象與其調用者在同一線程中,如果在Handler中設置了延時操作,則調用線程也會堵塞。每個Handler對象都會綁定一個Looper對象,每個Lo ...

2016-08-02 22:17 0 52188 推薦指數:

查看詳情

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

最近做項目時出現個問題。 在一個基類,創建一個Handler對象用於主線程線程發送數據,代碼如下 但不知道為啥一直報錯Can't create handler inside thread that has not called Looper.prepare()。 搜索后 ...

Mon Jan 14 00:10:00 CST 2013 3 133790
Can't toast on a thread that has not called Looper.prepare()

Android開發Can't toast on a thread that has not called Looper.prepare()問題 說一下問題出現場景:   在一個Android項目中,利用okhttp進行網絡訪問判斷用戶輸入的賬號密碼,當用戶密碼輸錯時彈出 Toast 進行提示 ...

Tue Nov 26 01:04:00 CST 2019 0 419
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM