IT/Android
[Android]java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 에러 해결 방법
Kanzler
2017. 2. 24. 07:30
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 에러가 발생 되는 경우는 thread 속에 thread를 사용 했기 때문입니다.
thread 안에서는 Handler 를 사용해서 처리 해야 합니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | class ThreadTest implements Runnable { @Override public void run() { // TODO Auto-generated method stub Handler mHandler = new Handler(Looper.getMainLooper()); mHandler.postDelayed(new Runnable() { @Override public void run() { // thread 속 thread 할일 } }, 0); } } | cs |