Reputation: 69
I use this function to check internet connection
public static bool IsConnectedToInternet()
{
ConnectionProfile connectionProfile = NetworkInformation.GetInternetConnectionProfile();
return (connectionProfile != null && connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess);
}
and it works fine if i am not connected to a network, but the problem appear when internet down and still connected this method return true. Is there another way to check internet connection perfectrly?
Upvotes: 1
Views: 853
Reputation: 131
That is the right API to use. But as Daniel said connectivity to the internet can mean a lot of things. Also note there is latency in detecting the loss and gain of the "internet connection".
It is possible to create a background task that will be invoked when the network connectivity is detected as InternetAvailable; see SystemTriggerType.
Upvotes: 1