NetworkOnMainThreadException in Service

前端 未结 4 1401
渐次进展
渐次进展 2021-01-19 19:15

I\'m getting a NetworkOnMainThreadException in my Service class, which by nature doesn\'t make sense, because Services are background processes as

4条回答
  •  萌比男神i
    2021-01-19 19:42

    The exception that is thrown when an application attempts to perform a networking operation on its main thread.

    This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged.

    http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

提交回复
热议问题