locked
WP8.1/win8.1中,如何获取wifi是开启的还是关闭的?手机网络是开启还是关闭的? RRS feed

  • 问题

  • 如题:
    WP8.1/win8.1中,如何获取wifi是开启的还是关闭的?当前是否连接到wifi?连接到wifi的ssid是多少?
    如何获取手机网络是开启还是关闭的?手机网络名称是什么(比如“中国移动”或“中国联通”)?
    2014年6月16日 6:29

答案

  • 你好,

    关于WP8.1平台下WIFI与手机网络的内容,请参考:

    http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/hh487166(v=vs.105).aspx

    关于如何获取WIFI SSID:请参考:

    public string GetSSIDName()
    {
        foreach (var network in new NetworkInterfaceList())
        {
            if (
                (network.InterfaceType == NetworkInterfaceType.Wireless80211) &&
                (network.InterfaceState == ConnectState.Connected)
                )
            {
                return network.InterfaceName;
            }
        }
        return "<Not connected>";
    }


    最后一个问题更确切的说是获取网络运营商的名称,

    using Microsoft.Phone.Net.NetworkInformation;
    
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("Mobile operator:  ");
    sb.AppendLine(DeviceNetworkInformation.CellularMobileOperator);
    MessageBox.Show(sb.ToString());

    http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/hh202875(v=vs.105).aspx

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月17日 7:23
    版主