Windows phone 8 如何检测WinRT应用程序的internet连接类型
Windows phone 8 如何检测WinRT应用程序的internet连接类型,windows-phone-8,windows-runtime,Windows Phone 8,Windows Runtime,我使用下面的代码来检测internet连接类型
我尝试了以下条件:
断开笔记本电脑的Wifi连接
断开笔记本电脑的电缆internet连接
问题是:
在上述1和2条件下,代码仍然生成结果:
接口类型6(“互联网连接(电缆))。这是怎么回事
我试过了,结果是一样的:
连接到Wifi
断开电缆与internet的连接
我错过了什么
private async void btnChkConnectionType_Click(object sender, RoutedEventArgs e)
我使用下面的代码来检测internet连接类型
我尝试了以下条件:
断开笔记本电脑的Wifi连接
断开笔记本电脑的电缆internet连接
问题是:
在上述1和2条件下,代码仍然生成结果:
接口类型6(“互联网连接(电缆))。这是怎么回事
我试过了,结果是一样的:
连接到Wifi
断开电缆与internet的连接
我错过了什么
private async void btnChkConnectionType_Click(object sender, RoutedEventArgs e)
{
var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var interfaceType = profile.NetworkAdapter.IanaInterfaceType;
// 71 is WiFi & 6 is Ethernet
if (interfaceType == 71 )
{
txtBlkConnectionStatus.Text = "WiFi connection";
}
else if(interfaceType == 6)
{
txtBlkConnectionStatus.Text = "Internet connection (cable)";
} //3G/Mobile Detect
else if (interfaceType == 243 || interfaceType == 244)
{
txtBlkConnectionStatus.Text = "Mobile Connection";
}
else
{
txtBlkConnectionStatus.Text = "Not common connection type.";
}
}
专用异步无效btnChkConnectionType_单击(对象发送方,路由目标)
{
var profile=Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
var interfaceType=profile.NetworkAdapter.IanaInterfaceType;
//71是WiFi,6是以太网
if(接口类型==71)
{
txtBlkConnectionStatus.Text=“WiFi连接”;
}
else if(interfaceType==6)
{
txtBlkConnectionStatus.Text=“互联网连接(电缆)”;
}//3G/移动检测
else if(interfaceType==243 | | interfaceType==244)
{
txtBlkConnectionStatus.Text=“移动连接”;
}
其他的
{
txtBlkConnectionStatus.Text=“非通用连接类型。”;
}
}
尝试使用本文中的一个示例
尝试使用本文中的一个示例