/**
  * 判断系统的网络是否可用
  * @return
  */
        private bool isNetworkConnected()
        {
            bool net = false;

            ConnectivityManager connManager = (ConnectivityManager)this.GetSystemService(ConnectivityService);

        // connManager.ActiveNetworkInfo ==null   手机无法连接网络
           if (connManager.ActiveNetworkInfo != null)
           {
               //获得 wifi 连接管理
               NetworkInfo networkInfo = connManager.GetNetworkInfo(ConnectivityType.Wifi);
               //获得 GPRS 连接管理
               NetworkInfo gp = connManager.GetNetworkInfo(ConnectivityType.Mobile);
               if (networkInfo != null && networkInfo.IsAvailable != false )
               {
                   Toast.MakeText(this, "WIFI打开!", ToastLength.Long).Show();
                   net = true;
               }
              // gp.IsConnected==false 有信号无网络
               if (gp!=null && gp.IsConnected != false)
               {
                   Toast.MakeText(this, "有信号gprs打开!", ToastLength.Long).Show();
                   net = true;
               }

      
            }
           return net;
          

        }

相关文章:

  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-15
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案