NetWork On main thread Exception

后端 未结 2 957
慢半拍i
慢半拍i 2020-12-04 02:29

Hi, I try to check network connectivity and Internet present by using following method

check = new ConnectionDetector(getApplicationContext());

2条回答
  •  粉色の甜心
    2020-12-04 03:10

    You can't make HTTP requests on the main thread, it would cause the UI to freeze up. So it throws that exception. You need to do it in an AsyncTask or another Thread.

提交回复
热议问题