Over a million developers have joined DZone.

Get Network Info on Windows Phone

DZone's Guide to

Get Network Info on Windows Phone

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

When you are developing your application, you keep in mind that you may not always have a network connection. You should prepare for this simi-connected environment.  To do this, you should use the Microsoft.Phone.Net.NetworkingInformation namespace. With this you can do things like, check to see if the network is available, determine the type of network the phone is using (CDMA, GSM), or find the MO (Mobile Operator)

bool IsConnected =
string MobileOperator = 
bool IsCellularDataEnabled = 
Microsoft.Phone.Net.NetworkInformation. DeviceNetworkInformation.IsCellularDataEnabled;       
bool IsCellularDataRoamingEnabled = 
Microsoft.Phone.Net.NetworkInformation DeviceNetworkInformation.IsCellularDataRoamingEnabled;
bool IsWifiEnabled =
Microsoft.Phone.Net.NetworkInformation. DeviceNetworkInformation.IsWiFiEnabled;

The NetworkInterfaceType is another good one to put to determine what type of speeds you are going to get.

Source:  http://thesociablegeek.com/2011/10/10/get-network-info-on-windows-phone/

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}