How to check if internet is available or not in app startup in android?

前端 未结 3 1382
梦如初夏
梦如初夏 2021-02-09 10:11

My app at first loads the datas from internet(I am using webservice) I want to check internet access at app startup.

  1. I will like to check if any forms of internet
3条回答
  •  滥情空心
    2021-02-09 11:06

    NetworkInfo i = conMgr.getActiveNetworkInfo();
      if (i == null)
        return false;
      if (!i.isConnected())
        return false;
      if (!i.isAvailable())
        return false;
      return true;
    

提交回复
热议问题