我如何检查3G,WIFI,EDGE,蜂窝网络中的Windows Phone 7? [英] How can I check for 3G, wifi, EDGE, Cellular Networks in Windows Phone 7?

查看:102
本文介绍了我如何检查3G,WIFI,EDGE,蜂窝网络中的Windows Phone 7?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查3G,WIFI,EDGE,蜂窝网络中的Windows Phone 7使用C#?

How can I check for 3G, wifi, EDGE, Cellular Networks in Windows Phone 7 using C#?

推荐答案

如果您可以用芒果(7.1)的SDK,如果你的方案涉及到使用套接字,有一个简单的方式来获得你刚才提出的连接NetworkInterfaceType /子类型的信息:

If you can use the Mango (7.1) SDK, and if your scenario involves using sockets, there's a trivial way to get the NetworkInterfaceType/SubType information for the connection you just made:

    NetworkInterfaceInfo netInterfaceInfo = socket.GetCurrentNetworkInterface();
    var type = netInterfaceInfo.InterfaceType;
    var subType = netInterfaceInfo.InterfaceSubtype;

没有必要使用NetworkInterface.NetworkInterfaceType属性(臭名昭著需要长达30秒返回);没有必要以触发主机名解析刚确定网络类型;没有必要听网络更改事件。

No need to use the NetworkInterface.NetworkInterfaceType property (which notoriously takes up to 30sec to return); no need to trigger a hostname resolution just to determine the network type; no need to listen to network change events.

当然,这个工作最好与DeviceNetworkInformation.IsNetworkAvailable或NetworkInterface.GetIsNetworkAvailable()一起 - 这些呼叫立即返回,无论你是在网络上还是不行。如果你是,你首先连接插座,当它连接发问: - )

Of course, this works best in conjunction with DeviceNetworkInformation.IsNetworkAvailable or NetworkInterface.GetIsNetworkAvailable() - those calls return immediately whether you're on a network or not. If you are, you connect the socket first and ask questions when it's connected :-)

最后请注意:芒果的DeviceNetworkInformation.IsWiFiEnabled提防 - 我认为这将返回是否我是一个WiFi网络上,而是它返回的wifi是否在手机设置中开启或关闭...不是超级有用。

A final note: beware of Mango's DeviceNetworkInformation.IsWiFiEnabled - I thought it would return whether I was on a wifi network, but instead it returns whether wifi is turned on or off in the phone settings... not super useful.

这篇关于我如何检查3G,WIFI,EDGE,蜂窝网络中的Windows Phone 7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆