Tuesday, June 12, 2012


i am facing problem, when i am try access weburl using HTTPClient  Android SDK Versiong above 9  i got 
android.os.NetworkOnMainThreadException error.
Below i added solution for this one, you can check it.
06-12 18:21:57.192: W/System.err(19398): android.os.NetworkOnMainThreadException
06-12 18:21:57.202: W/System.err(19398): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1084)
06-12 18:21:57.202: W/System.err(19398): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:74)
06-12 18:21:57.202: W/System.err(19398): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
06-12 18:21:57.212: W/System.err(19398): at libcore.io.IoBridge.connect(IoBridge.java:112)
06-12 18:21:57.212: W/System.err(19398): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
06-12 18:21:57.222: W/System.err(19398): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
06-12 18:21:57.222: W/System.err(19398): at java.net.Socket.connect(Socket.java:842)
Solution :
Activity  onCreate method  add this code.
if (android.os.Build.VERSION.SDK_INT > 9) {

StrictMode.ThreadPolicy policy =

new StrictMode.ThreadPolicy.Builder().permitAll().build();


What is StrictMode?  
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive
More Check this link

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...