检查手机的互联网连接 [英] Check internet Connection on phone

查看:201
本文介绍了检查手机的互联网连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查我的手机是否能够连接到互联网或没有。我见过几个问题了。其中之一是<一个href="http://stackoverflow.com/questions/13617017/windows-phone-8-connection-handler-internet-availability">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.

这篇关于检查手机的互联网连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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