NetworkOnMainThreadException in Service

前端 未结 4 1400
渐次进展
渐次进展 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:46

    onStartCommand() runs on the UI thread in a Service. Try using IntentService, or alternatively use any other threading method in the Service (Handler/Runnable, AsyncTask).

提交回复
热议问题