In “onCreate” method, I have a line of code,
Drawable.createFromStream(((java.io.InputStream) new java.net.URL(url).getContent()), "");
When I run it on smartphone(Samsung Duos), it works well. But when I run it on Toshiba Thrive tablet, I get "android.os.NetworkOnMainThreadException" exception.
Why does it happen?
In the newer versions of Android since
3.0, you can’t run Network activities on the Main UI thread.Those get killed automatically, as it leads to a bad user experience anyway.
NetworkOnMainThreadException
Run it on a different thread, maybe use AsyncTask