When i try to read single line of text from website i get error (NetworkOnMainThreadException). I tryed few thing but nothing works so far. So here is code if anyone could h
You might want to do all your downloading using a AsyncTask, http://developer.android.com/reference/android/os/AsyncTask.html
or if your on api 11+ a AsyncTaskLoader, http://developer.android.com/reference/android/content/AsyncTaskLoader.html
don't use network activities in main thread.This exception only thrown for applications targeting the Honeycomb SDK or higher. perform all the network related task in separate thread ( either use handler looper or runOnUiThread) . your problem will get solved.
Either you can move it to background thread or if you just want to eliminate this error just add this in your onCreate() :
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Do not forget to add internet permission in manifest:
<uses-permission android:name="android.permission.INTERNET"/>