Quantcast
Channel: How can I fix 'android.os.NetworkOnMainThreadException'? - Stack Overflow
Viewing all articles
Browse latest Browse all 191

Answer by prat3ik-patel for How can I fix 'android.os.NetworkOnMainThreadException'?

$
0
0

You have to simply add the following line in file manifest.xml after the manifest tag

<uses-permission android:name="android.permission.INTERNET"/>

And in the activity file, add the following code after the binding statement:

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

Viewing all articles
Browse latest Browse all 191

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>