IT/안드로이드

안드로이드스튜디오 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

조원태 2017. 2. 21. 04:45
반응형

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




쓰레드 안에 쓰레드를 넣었기 때문에 발생하는 에러입니다.



        Handler mHandler = new Handler(Looper.getMainLooper());

        mHandler.postDelayed(new Runnable() {

            @Override

            public void run() {

              //실행 내용

            }

        }, 1000);


1000은 1초를 의미합니다. 


postDelayed는 시간 이후 실행

그러니까 1초 후 run에 내용을 실행하게 됩니다. 



반응형