In almost every mobile application I’m building, offline support is a must have. So one of the things I always have to do is check if an Internet connection is available.
To help me remember this, a small code snippet that does the job:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsConnectedToInternet() | |
{ | |
ConnectionProfile connectionProfile = NetworkInformation.GetInternetConnectionProfile(); | |
return (connectionProfile!=null && connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAcces); | |
} |