Moises Jimenez
Moises Jimenez

Reputation: 1962

Android: NetworkOnMainThreadException on Thread

Just as the title says. I'm getting this error when starting a Service that uses sockets. How come?

Upvotes: 0

Views: 232

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007349

Because you are attempting to use sockets on the main application thread, perhaps from onStartCommand(). Please do network I/O on a background thread.

Upvotes: 2

Related Questions