Search This Blog

Wednesday, March 14, 2012

android - DefaultHttpClient to AndroidHttpClient - Stack Overflow

while accessing the WEB on the main thread i get the next exception
AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)

"StrictMode.ThreadPolicy was introduced since API Level 9 and the default thread policy had been changed since API Level 11, which in short, does not allow network operation (include HttpClient and HttpUrlConnection) get executed on UI thread. if you do this, you get NetworkOnMainThreadException.

This restriction can be changed, using:

    if (android.os.Build.VERSION.SDK_INT > 9) {
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
    }"

more android - DefaultHttpClient to AndroidHttpClient - Stack Overflow:

Yaniv Tzanany

1 comment:

Android app deeveloper said...

This is one of the resource-able and good post.I like your blog logic.Great work.
Android app developer