NetworkOnMainThreadException in Service

前端 未结 4 1351
渐次进展
渐次进展 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条回答
  •  失恋的感觉
    2021-01-19 19:34

    Service callbacks all run on the main thread, aka the UI thread. If you wish to do background work, either start a Thread, or use IntentService's onHandleIntent(Intent i).

提交回复
热议问题