在子線程中使用Toast的時候,出現Force close。
錯誤提示:Can't create handler inside thread that has not called Looper.prepare()
解決方法:
1 Looper.prepare(); 2 Toast.makeText(ActivityTestActivity.this, "toast", 1).show(); 3 Looper.loop();
原因:
子線程只是一個普通的線程,其ThreadLoacl中沒有設置過Looper,所以會拋出異常