コード例 #1
0
        private void CheckConnectionStatus()
        {
            var remoteHostStatus = Reachability.RemoteHostStatus();
            var internetStatus   = Reachability.InternetConnectionStatus();
            var localWifiStatus  = Reachability.LocalWifiConnectionStatus();

            IsConnected = (internetStatus != NetworkStatus.NotReachable) || (localWifiStatus != NetworkStatus.NotReachable) ||
                          (remoteHostStatus != NetworkStatus.NotReachable);
        }
コード例 #2
0
 public Connectivity()
 {
     Reachability.ReachabilityChanged += (sender, args) =>
     {
         var remoteHostStatus = Reachability.RemoteHostStatus();
         var internetStatus   = Reachability.InternetConnectionStatus();
         var localWifiStatus  = Reachability.LocalWifiConnectionStatus();
         IsConnected = (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                        internetStatus == NetworkStatus.ReachableViaWiFiNetwork) ||
                       (localWifiStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                        localWifiStatus == NetworkStatus.ReachableViaWiFiNetwork) ||
                       (remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork ||
                        remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork);
     };
 }