Windows Phone 7 gets the current network type (whether the device is connected to the PC through Zune)

Source: Internet
Author: User
///   <Summary>  
/// Determine whether the Network is available
/// </Summary>
/// <Returns> True or false </Returns>
Public Static Bool Querynetworkstatus ()
{
Return Microsoft. Phone. net. networkinformation. networkinterface. getisnetworkavailable (); // Whether the current network is available
}
/// <Summary>
/// Obtain the current network type
/// </Summary>
/// <Returns> </returns>
Public Static Type querynetworktype ()
{
Networkinterfacetype _ currentnetworktype = Microsoft. Phone. net. networkinformation. networkinterface. networkinterfacetype; // Obtain the current network type
Type type;
Switch (_ Currentnetworktype)
{
Case Networkinterfacetype. mobilebroadbandcdma:
// "CDMA network ";
Type = type. CDMA network;
Break ;
Case Networkinterfacetype. mobilebroadbandgsm:
// "Csm network ";
Type = type. CSM network;
Break ;
Case Networkinterfacetype. wireless80211:
// "Wireless network ";
Type = type. Wireless Network;
Break ;
Case Networkinterfacetype. Ethernet:
// "Ethernet network ";
Type = type. Ethernet network;
Break ;
Case Networkinterfacetype. None:
// "Network unavailable ";
Type = type. The network is unavailable;
Break ;
Default :
// "Other networks ";
Type = type. Other networks;
Break ;
}
Return Type;
}
/// <Summary>
/// Network Type
/// </Summary>
Public Enum Type
{
CDMA network,
CSM network,
Wireless Network,
Ethernet network,
Network unavailable,
Other networks,
}
}
}

to determine whether the current mobile phone is connected to the PC through Zune, debug it under the device. The connection type of the current simulator is wireless80211

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.