Answered by:
Detect connection type (Wifi/3G...)

Question
-
Is there a way to detect current network connection type between Ethernet/Wifi/3G etc...? Inside connectivity sample i can get many informations but can't find this one.
Cheers,
Corrado Cavalli [Microsoft .NET MVP-MCP]
UGIdotNET - http://www.ugidotnet.org
Weblog: http://blogs.ugidotnet.org/corrado/
Twitter: http://twitter.com/corcav- Edited by Corrado Cavalli [MVP]MVP Monday, June 4, 2012 11:04 AM
Monday, June 4, 2012 11:04 AM
Answers
-
If you just want to know the connection type (ethernet/wireless/etc) you can do that with the NetworkAdapter's IANAInterfaceType: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.connectivity.networkadapter.ianainterfacetype.aspx
For example:
var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile(); if (profile) { var interfaceType = profile.networkAdapter.ianaInterfaceType; if (interfaceType === 71) { console.log('on Wireless'); } else if (interfaceType === 6) { console.log('on Ethernet'); } else { console.log('on something weird...'); } }
I'm not sure how the cost stuff works, but I think it's just for 3G/metered connections where Windows can get rate information. I think the above should be good enough if you just want to do something simple like switch to higher fidelity video streams when people are plugged in versus on wireless.
Cheers,
-Jeff
- Marked as answer by Dino He Tuesday, June 12, 2012 7:54 AM
Wednesday, June 6, 2012 8:30 PM
All replies
-
Hi Corrado,
What are you doing with this information? I think this is what you want but it would help to know your scenario: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.connectivity.networkcosttype.aspx
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, June 4, 2012 12:21 PM
Monday, June 4, 2012 12:21 PMModerator -
Hi Jeff,
I have some content that can be accessed only over wired or Wifi connection that's why i need to detect connection type ( as i do in Windows Phone)
Corrado Cavalli [Microsoft .NET MVP-MCP]
UGIdotNET - http://www.ugidotnet.org
Weblog: http://blogs.ugidotnet.org/corrado/
Twitter: http://twitter.com/corcavMonday, June 4, 2012 2:25 PM -
Hi Corrado,
It sounds like the link I provided (cost type) should get you what you need then. Also see this quickstart:
http://msdn.microsoft.com/en-us/library/windows/apps/hh750310.aspx
-Jeff
Jeff Sanders (MSFT)
- Proposed as answer by Jeff SandersMicrosoft employee, Moderator Monday, June 4, 2012 4:28 PM
Monday, June 4, 2012 4:28 PMModerator -
If you just want to know the connection type (ethernet/wireless/etc) you can do that with the NetworkAdapter's IANAInterfaceType: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.connectivity.networkadapter.ianainterfacetype.aspx
For example:
var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile(); if (profile) { var interfaceType = profile.networkAdapter.ianaInterfaceType; if (interfaceType === 71) { console.log('on Wireless'); } else if (interfaceType === 6) { console.log('on Ethernet'); } else { console.log('on something weird...'); } }
I'm not sure how the cost stuff works, but I think it's just for 3G/metered connections where Windows can get rate information. I think the above should be good enough if you just want to do something simple like switch to higher fidelity video streams when people are plugged in versus on wireless.
Cheers,
-Jeff
- Marked as answer by Dino He Tuesday, June 12, 2012 7:54 AM
Wednesday, June 6, 2012 8:30 PM