I have an app where the user submits some data in a form which is then sent to a server. I am testing it on a tablet and an Android smartphone (Galaxy S2). On the tablet, as soo
NetworkOnMainThreadException: The exception that is thrown when an application attempts to perform a networking operation on its main thread.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
AsyncTaskclass RetreiveFeedTask extends AsyncTask {
private Exception exception;
protected RSSFeed doInBackground(String... urls) {
try {
// add your all code here
} catch (Exception e) {
this.exception = e;
return null;
}
}
protected void onPostExecute(RSSFeed feed) {
// TODO: check this.exception
// TODO: do something with the feed
}
}
to execute the AsyncTask:
new RetreiveFeedTask().execute(urlToRssFeed);
hope you have added below permission in android manifest file