Пример #1
0
        /// <summary>
        /// Gets the network connectivity level for this connection.
        /// This value indicates what network resources, if any, are currently available.
        /// </summary>
        /// <returns></returns>
        public NetworkConnectivityLevel GetNetworkConnectivityLevel()
        {
#if __ANDROID__
            if (_info.IsConnected)
            {
                return(NetworkConnectivityLevel.InternetAccess);
            }

            return(NetworkConnectivityLevel.None);
#elif __UNIFIED__
            switch (_flags)
            {
            case NetworkReachabilityFlags.Reachable:
                return(NetworkConnectivityLevel.InternetAccess);

            default:
                return(NetworkConnectivityLevel.None);
            }
#elif TIZEN
            switch (_item.State)
            {
            case Tizen.Network.Connection.ConnectionState.Connected:
                return(NetworkConnectivityLevel.InternetAccess);

            default:
                return(NetworkConnectivityLevel.None);
            }
#elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            return((NetworkConnectivityLevel)((int)_profile.GetNetworkConnectivityLevel()));
#elif WIN32
            return(_interface.OperationalStatus == OperationalStatus.Up ? NetworkConnectivityLevel.InternetAccess : NetworkConnectivityLevel.None);
#else
            return(NetworkConnectivityLevel.None);
#endif
        }
        private static bool IsInternetConnected()
        {
            Windows.Networking.Connectivity.ConnectionProfile connections = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
            bool internet = (connections != null) &&
                            (connections.GetNetworkConnectivityLevel() == Windows.Networking.Connectivity.NetworkConnectivityLevel.InternetAccess);

            return(internet);
        }
Пример #3
0
        private bool CheckInternetAccess()
        {
            bool internetAccess = false;

            Windows.Networking.Connectivity.ConnectionProfile connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

            if (connectionProfile != null)
            {
                var connectivityLevel = connectionProfile.GetNetworkConnectivityLevel();
                if (connectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.ConstrainedInternetAccess ||
                    connectivityLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.InternetAccess)
                {
                    internetAccess = true;
                }
            }

            return(internetAccess);
        }
Пример #4
0
 private bool IsConnectedToInternet()
 {
     Windows.Networking.Connectivity.ConnectionProfile connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
     return(connectionProfile != null && connectionProfile.GetNetworkConnectivityLevel() == Windows.Networking.Connectivity.NetworkConnectivityLevel.InternetAccess);
 }