The below method works for me simply to check if the device is connected to the Internet or even in the universal Windows application. After creating the connection class, you can simply use it anywhere, simply by creating an instance of this class ...
public class Connection { public bool CheckInternetAccess() { var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); var HasInternetAccess = (connectionProfile != null && connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess); return HasInternetAccess; } }
To use this class is simple ..
Connection objConnection = new Connection(); if(objConnection.CheckInternetAccess()==true) { //todo } else {//todo}
source share