NetworkOnMainThreadException [duplicate]
With honeycomb you can not perform a networking operation on its main thread as documentation says. For this reason you must use handler or asynctask. There is no another way to do it.
here you can find 2 examples written in turkish about networking operation. maybe they help.
3. party kütüphane kullanmadan (ksoap2), (it includes english translation)
AsyncTask class'tan dönen parametreyi handle etmek. , google translate
I have tested this and it does in fact happen on the emulator as well. Better make sure you test your app at least on the emulator if you plan to get it onto the 3.0 tablets and beyond.
NetworkOnMainThreadException
occurs when some networking operations are performed inside main method; I mean Oncreate()
. You can use AsyncTask
for resolving this issue. or you can use
StrictMode.ThreadPolicy mypolicy = new StrictMode.ThreadPolicy.Builder().permitAll().build();StrictMode.setThreadPolicy(policy);
inside onCreate()
method.