简体   繁体   English

在uwp分配中检测Internet连接类型?

[英]detect internet connection type in uwp allication?

I am developing a uwp application that builds to windows store and xbox basically. 我正在开发一个uwp应用程序,该应用程序基本上可以构建到Windows store和xbox。

My code is like 我的代码就像

var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
     var networkType=null;
     var interfaceType = profile.NetworkAdapter.IanaInterfaceType;
        // 71 is WiFi & 6 is Ethernet
        if (interfaceType == 71) 
        {
          networkType="wifi";
        }

        else if (interfaceType == 6)
        {
          networkType="ethernet";
        }

when i was connected to wifi and run this code in xbox i am getting the connection type as "ethernet", but when i run the same code on my local machine i am getting the value as wifi. 当我连接到wifi并在xbox中运行此代码时,我得到的连接类型为“以太网”,但是当我在本地计算机上运行相同的代码时,我得到的值为wifi。

Any helps appreciated:) 任何帮助表示赞赏:)

Since you are using the NetworkAdapter class, if you check the device family of this class: 由于您使用的是NetworkAdapter类,因此,如果检查此类的设备系列,则:

Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox) Windows 10(已推出v10.0.10240.0-适用于Xbox,请参阅Xbox尚不支持的UWP功能)

For Xbox, we need to check the UWP features not yet supported on Xbox , and NetworkInformation is in "Feature areas less applicable to Xbox" section. 对于Xbox,我们需要检查Xbox尚不支持UWP功能 ,并且NetworkInformation位于“不适用于Xbox的功能区域”部分。

NetworkUsage, ConnectivityInterval, NetworkInformation, and DataPlanStatus APIs are not supported on Xbox. Xbox不支持NetworkUsage,ConnectivityInterval,NetworkInformation和DataPlanStatus API。

So it seems like it is currently not completely supported. 因此,似乎目前尚不完全支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM