今天在檢查友盟提交反饋的時候發(fā)現(xiàn)一個bug:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.PRepare()經(jīng)過檢查發(fā)現(xiàn),有9處調(diào)用,其他八處都是主線程,只有new Timer().schedule(new TimerTask() { @Override public void run() { .... }}, 4000);這里才會出問題, 原因在于Timer其實是一個線程,所以handler = new Handler(); 是錯誤的,必須加上Looper.prepare();...Looper.loop();
新聞熱點
疑難解答