반응형
UI 쓰레드가 아닌 일반 쓰레드에서 UI 작업처리를 위해 new Handler() 를 통해 Handler를 사용할 경우 아래와 같은 에러가 발생합니다.
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
http://stackoverflow.com/questions/6369287/accessing-ui-thread-handler-from-a-service
I believe this snippet of code constructs a Handler associated with the main (UI) thread:
Handler handler = new Handler(Looper.getMainLooper());
You can then post stuff for execution in the main (UI) thread like so:
handler.post(something_to_run_on_main_thread);
반응형
'프로그래밍 > 안드로이드' 카테고리의 다른 글
EditText 포커스 뒤쪽으로 위치하기 (0) | 2012.11.20 |
---|---|
Location of the Android SDK has not been setup in the preferences (0) | 2012.11.15 |
이미지의 Orientation를 체크해서 이미지 회전하기 (0) | 2012.10.31 |
안드로이드 SMS Content URI (0) | 2012.10.31 |
xml 특수문자 치환 (0) | 2011.08.09 |