The NetworkHelper class provides functionality to monitor changes in network connection and allows users to query for network information without additional lookups.
It exposes network information though a property called ConnectionInformation. The ConnectionInformation holds information about ConnectionType, ConnectivityLevel, ConnectionCost, SignalStrength, Internet Connectivity and more.
What is a metered connection?
A metered connection is an Internet connection that has a data limit or cost associated with it. Cellular data connections are set as metered by default. Wi-Fi network connections can be set to metered, but aren't by default. Application developers should take metered nature of connection into account and reduce data usage.
Gets connectivity level for the current Internet Connection Profile
IsInternetAvailable
bool
Gets a value indicating whether internet is available across all connections
IsInternetOnMeteredConnection
bool
Gets a value indicating whether if the current internet connection is metered
NetworkNames
IReadOnlyList<string>
Gets signal strength for the current Internet Connection Profile
SignalStrength
Nullable<Byte>
Gets signal strength for the current Internet Connection Profile
ConnectionInformation Methods
Methods
Return Type
Description
UpdateConnectionInformation(ConnectionProfile)
void
Updates the current object based on profile passed
NetworkHelper Events
Events
Description
NetworkChanged
Event raised when the network changes
Example
// Detect if Internet can be reached
if (NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
{
}
// Detect if the connection is metered
if (NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{
}
// Get precise connection type
switch(NetworkHelper.Instance.ConnectionInformation.ConnectionType)
{
case ConnectionType.Ethernet:
// Ethernet
break;
case ConnectionType.WiFi:
// WiFi
break;
case ConnectionType.Data:
// Data
break;
case ConnectionType.Unknown:
// Unknown
break;
}
' Detect if Internet can be reached
If NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable Then
...
End If
' Detect if the connection is metered
If NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection Then
...
End If
' Get precise connection type
Select Case NetworkHelper.Instance.ConnectionInformation.ConnectionType
Case ConnectionType.Ethernet
' Ethernet
Case ConnectionType.WiFi
' WiFi
Case ConnectionType.Data
' Data
Case ConnectionType.Unknown
' Unknown
End Select