Android - android.os.NetworkOnMainThreadException

后端 未结 8 1190
迷失自我
迷失自我 2020-11-22 08:15

I have this exception and I was reading a thread on this, and it seemed confusing:

How to fix android.os.NetworkOnMainThreadException?

I already added this l

8条回答
  •  既然无缘
    2020-11-22 08:56

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

    You should call sendfeedback method on asynctask then only above code will work. As webserver is taking lot of time to response main thread becomes unresponsive. To avoid it you should call it on another thread. Hence asynctask is better.

    here is link that illustrates how to use asynctask

提交回复
热议问题