android.os.NetworkOnMainThreadException

android.os.NetworkOnMainThreadException -> execution error
correct source(after)

 

wrong source (before)

impossible to connet network in main UI thread after Android 3.0 version
so you must create other thread

cite from -> http://ironheel.tistory.com/48

사실 위 코드에는 문제가 전혀 없다.
문제는 android가 변했다는 점이다.

결론부터 말하자면 honeycomb에서는 main thread(UI)에서 네트워크 호출을 하면 무조건 error로 간주한다.

앱 전체의 thread와 컨트롤을 관리하는 main에서 네트워크 호출로 대기중인 시간이 길어지면
사용자는 안드로이드앱의 문제로 인식하게 된다. 이를 방지하자는 것이 목적이다.
다음 링크를 참조하자 :  painless threading 번역글

This entry was posted in Android. Bookmark the permalink.

Leave a Reply