Domanda

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

È stato utile?

Soluzione

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top