Quick Tip #3 – Checking for Internet Connectivity

How do we get to know whether the app has internet connectivity? This is important when you want to check for connectivity before doing a server sync.

 public static bool IsInternetAvailable
 {
   get
    {
     var profiles = NetworkInformation.GetConnectionProfiles();
     var internetProfile = NetworkInformation.GetInternetConnectionProfile();
     return profiles.Any(s => s.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess) || (internetProfile != null && internetProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess);
    }
 }

May the code be with you! 😀

logosmall

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s