简体   繁体   中英

detect internet connection type in uwp allication?

I am developing a uwp application that builds to windows store and xbox basically.

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.

Any helps appreciated:)

Since you are using the NetworkAdapter class, if you check the device family of this class:

Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)

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.

NetworkUsage, ConnectivityInterval, NetworkInformation, and DataPlanStatus APIs are not supported on Xbox.

So it seems like it is currently not completely supported.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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