Windows Phone 7 checking for Internet Connection

141 views Asked by At
Dim _isNetworkAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsWiFiEnabled

always returns false though I do have internet connection.
I'm testing on the emulator, could that be the source of the issue?

How I'm testing: I have a button that calls the above code and displays the result of the boolean in a textbox

1

There are 1 answers

2
har07 On BEST ANSWER

Your current code only check whether Wifi enabled or not on the device, which will always return false if you run in emulator. Because there is no interface to set Wifi enabled in WP7 emulator. You need to use IsNetworkAvailable property instead, to check if any internet connection available. See this MSDN link for reference. So your code should be as follow :

Dim _isNetworkAvailable = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable