Making a call to a REST WebService in a Service class of my Android app create the NetworkOnMainThreadException.
I understand why this exception is raised in an Activity : fetching something over the network synchronously is an extremely bad practice but I am surprised to see that same error in a Service Class. So my question is :
-In this specific case, should I use StrictMode.setThreadPolicy() to allow this call. (And for those that read this because they have encountered this error in an activity, don't use StrictMode to hide this error, use an AsyncTask)
-or should I use an AsyncTask ? And in that case, what is the issue here ? Isn't the service on a thread separated from the Activity's one ?