我想检查我的手机是否能够连接到互联网或没有。我见过几个问题了。其中之一是Question 。它说,使用 NetworkInterface.GetIsNetworkAvailable()
这一点,我想它。我已经断开我的电脑从互联网上,也关掉了 DataConnection
模拟器,但 NetworkInterface.GetIsNetworkAvailable()
这始终返回true。但simultaneouly我也检查 NetworkInterfaceType.None
键,有趣的是它是未来空。
任何人都可以解释我在哪里丢失的信息?
I wanted to check whether my phone can connect to Internet or not. I have seen several questions already. One of those is Question . It says to use NetworkInterface.GetIsNetworkAvailable()
this and i tried it. I have disconnected my PC from internet and Also turned off the DataConnection
of the emulator but NetworkInterface.GetIsNetworkAvailable()
this always returning true. But simultaneouly i also check for NetworkInterfaceType.None
and interestingly it is coming null.
Can anybody explain where i am missing info ?
尝试: -
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;
}
任何帮助是AP preciated:)
any help is appreciated :)
模拟器总是返回 NetworkInterface.GetIsNetworkAvailable()
为真,即使你模拟网络条件有没有网络。
The emulator always returns NetworkInterface.GetIsNetworkAvailable()
as true, even if you emulate network conditions as having no network.
我面对这个问题,我和唯一的出路真正测试这种行为是运行Windows手机将应用程序部署到物理设备进行测试与数据关闭。
I faced this problem myself and the only truly way of testing this behaviour is to deploy the application to a physical device running Windows Phone and test it with the data turned off.