Android - android.os.NetworkOnMainThreadException

后端 未结 8 1188
迷失自我
迷失自我 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

    After a long research (lasted half day) I have found a solution for my problem which is similar to the problem indicated here. The exception displayed by my Android Studio 2.3.3 was this:

    android studio android.os.networkonmainthreadexception

    The problem was based on the impossibility to set a UI variable in the MainActivity. So I saw the following video and I solved my problem. I hope it is also useful to others:

    How to avoid android os NetworkOnMainThreadException

    0 讨论(0)
  • 2020-11-22 09:01

    You made network call on main thread which is against to android rules, so you have to do your network call on separate thread like asynctask or handler etc.

    0 讨论(0)
提交回复
热议问题