It is always better to detect the network connectivity and network type before performing any task on mobile devices. You can use GSM/EDGE/CDMA network for normal login functionality, updating status messages or perform normal task which doesn’t require huge bandwidth. Whereas, you can rely on WiFi or Ethernet (USB Connection) for synchronizing huge data like pictures, videos or audio files.
For checking network and its type, Windows Phone 7 consists two assemblies/namespaces.
However, you should use the second one (Microsoft.Phone.Net.NetworkInformation) for performing the tasks on devices. You can enumerate through network like:
1: switch (NetworkInterface.NetworkInterfaceType)
3: case NetworkInterfaceType.Ethernet:
4: //Do something when Ethernet or
5: //USB connectivity is available
7: case NetworkInterfaceType.MobileBroadbandCdma:
8: //Do something when CDMA network
9: //is available
11: case NetworkInterfaceType.MobileBroadbandGsm:
12: //Do something when CDMA
13: //network is available
15: case NetworkInterfaceType.None:
16: //The is no network
18: case NetworkInterfaceType.Unknown:
19: //Connected network type is unknown
21: case NetworkInterfaceType.Wireless80211:
22: //When device is connected to WiFi
Using this code you can execute your code depending on network interface type.
Find related post on MSDN: Click here
Mayur Tendulkar | www.mayurtendulkar.com