【发布时间】:2014-08-04 11:04:44
【问题描述】:
我想检查我的手机是否可以连接到互联网。我已经看到了几个问题。其中之一是 Question 。它说要使用NetworkInterface.GetIsNetworkAvailable() 这个,我试过了。我已经断开了我的电脑与互联网的连接,还关闭了模拟器的 DataConnection,但 NetworkInterface.GetIsNetworkAvailable() 这总是返回 true。但同时我也检查了NetworkInterfaceType.None,有趣的是它即将为空。
谁能解释我在哪里缺少信息?
尝试:-
public static void CheckNetworkAvailability()
{
// this is coming true even when i disconnected my pc from internet.
// i also make the dataconnection off of the emulator
var fg = NetworkInterface.GetIsNetworkAvailable();
var ni = NetworkInterface.NetworkInterfaceType;
// this part is coming none
if (ni == NetworkInterfaceType.None)
IsConnected = false;
}
任何帮助表示赞赏:)
【问题讨论】:
-
一般情况下您会使用 Internet,还是在检查是否可以连接到后端服务器?
标签: c# .net windows-phone-8 windows-phone-8.1 windows-phone-sl-8.1