Development of Windows Phone 7: checking the mobile network

Source: Internet
Author: User
Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using system. net. networkinformation; using Microsoft. phone. net. networkinformation; namespace checknet {public partial class mainpage: phoneapplicationpage {private bool networkisavailable; private networkinterfacetype _ currentnetworktype; // public mainpage () {initializecomponent ();} private void button#click (Object sender, routedeventargs e) {networkisavailable = Microsoft. phone. net. networkinformation. networkinterface. getisnetworkavailable (); // whether the current network is available _ currentnetworktype = Microsoft. phone. net. networkinformation. networkinterface. networkinterfacetype; // obtain the current network type if (networkisavailable) {message. TEXT = "Networking status"; message. background = new solidcolorbrush (colors. green);} else {message. TEXT = "disconnected"; message. background = new solidcolorbrush (colors. red);} switch (_ currentnetworktype) {Case networkinterfacetype. mobilebroadbandcdma: netname. TEXT = "CDMA network"; break; Case networkinterfacetype. mobilebroadbandgsm: netname. TEXT = "csm network"; break; Case networkinterfacetype. wireless80211: netname. TEXT = "wireless network"; break; Case networkinterfacetype. ethernet: netname. TEXT = "Ethernet network"; break; Case networkinterfacetype. none: netname. TEXT = "Network unavailable"; break; default: netname. TEXT = "other networks"; break ;}}}}

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.