vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Friday, September 14, 2012

android.os.NetworkOnMainThreadException


Hi..
When I work with android web service project,From starting I used my application in android mobile its working perfectly with webservice,But when I move tablet its shows an below error.
Reason tablet have API 12, Thread policy has changed from the API Level 11
When you are using web service if it take more time then you can get the this type of error..
To overcome this error you have to add the below code on the starting of web service code.

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

After I used the above my problem would be solved. I hope it will help someone…
Post your valuable comments here………

0 comments:

Post a Comment