Reputation: 85845
I don't get what DeviceNetworkInformation.IsNetworkAvailable
actually does? Is this for checking for phone service and data service at the same time? I was sort of expecting to see a property to check if you can make calls, it seems to have everything else.
Upvotes: 2
Views: 470
Reputation: 4359
As Den Delimarsky said, you can not specifically get if it is possible to make a call etc, but in addition to DeviceNetworkInformation
you can use NetworkInterfaceList to get all network interfaces the phone is connected to, and that way see if it got GSM or CDMA cellular connection.
An example which shows all interfaces the phone is currently connected to:
NetworkInterfaceList networkInterfaces = new NetworkInterfaceList();
foreach (NetworkInterfaceInfo info in networkInterfaces)
{
if (info.InterfaceType == NetworkInterfaceType.MobileBroadbandCdma)
Debug.WriteLine("On CDMA network");
else if (info.InterfaceType == NetworkInterfaceType.MobileBroadbandGsm)
Debug.WriteLine("On GSM network");
else if (info.InterfaceType == NetworkInterfaceType.Ethernet)
Debug.WriteLine("On ethernet (PC pass-through)");
else if (info.InterfaceType == NetworkInterfaceType.None)
Debug.WriteLine("No network interface available");
else if (info.InterfaceType == NetworkInterfaceType.Wireless80211)
Debug.WriteLine("On 802.11 network (WiFi, Blutooth etc.)");
}
Upvotes: 0
Reputation: 16826
DeviceNetworkInformation.IsNetworkAvailable
refers to the network interface, not the phone network per-se (although it can be in case of data usage). If you have an active WiFi network that is linked to the device, you can still use this property to determine whether there is an active connection.
Upvotes: 1