开发者

How to determine if someone is connected to the internet in WP7?

I wrote a simple if statement to check first is someone was connected to the internet using the NetworkInterface.GetIsNetworkAvailable() me开发者_JAVA技巧thod:

if (NetworkInterface.GetIsNetworkAvailable())
{
    //EXECUTE
}
else
{
    //DISPLAY MESSAGE TO CONNECT TO INTERNET
}

Everytime I run it though it keeps returning true. I've actually disconnected it from the internet, wifi, and even tried airplane mode with no success. Any suggestions?


MrLacey has seen this in the emulator and when debugging - http://blog.mrlacey.co.uk/2010/12/wp7dev-gotchas-when-detecting-network.html

  1. If you call this method in code running in the emulator it will always return true.

  2. If you call this method in code running on a tethered device (as you may have connected when debugging on a real device) it will always return true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜