Windows 10 UWP - 检测当前的互联网连接是 Wifi 还是 Cellular? [英] Windows 10 UWP - detect if the current internet connection is Wifi or Cellular?

查看:21
本文介绍了Windows 10 UWP - 检测当前的互联网连接是 Wifi 还是 Cellular?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 10 UWP 应用中,我如何检测当前的互联网连接是 Wifi 还是 Cellular?

In Windows 10 UWP app how do I detect if the current internet connection is Wifi or Cellular?

推荐答案

在 UWP 中,您可以使用 IsWlanConnectionProfile 或 IsWwanConnectionProfile 属性检查网络连接.

In UWP you can check network connectivity using the IsWlanConnectionProfile or IsWwanConnectionProfile properties.

一个例子是:

var temp = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

if (temp.IsWlanConnectionProfile)
{
     // its wireless
}else if (temp.IsWwanConnectionProfile)
{
     // its mobile
}

我希望这会有所帮助.

这篇关于Windows 10 UWP - 检测当前的互联网连接是 Wifi 还是 Cellular?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆