On ICS, I’m getting an android.os.NetworkOnMainThreadException error when using UrlConnection – even though I’m making this request in a Service that runs on it’s own process, and was called asyncronously to be done via Messenger.
Changing the StrictPolicy had no effect, I still get the error.
What can I do?
edit: this Service runs in a separate process – has a different pid and everything.
Services still run on the main thread, as per the the documentation:
Therefore for long running tasks (such as using a UrlConnection) you should either use something like an IntentService or spawn a new Thread yourself.