Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WP7 How to debug airplane mode on device?

Is there a way to debug airplane mode on the device? I tried turning airplane mode on in the device settings and disabling the internet connection on my computer, but NetworkInterface.GetIsNetworkAvailable() still returns true. Am I doing something wrong?

like image 569
CACuzcatlan Avatar asked Feb 03 '11 01:02

CACuzcatlan


2 Answers

Notice the comment on the bottom of the official doc:

This API will always return true on the Windows Phone 7 emulator. Testing therefore requires a facade, mock or conditional chunk of code.

I just tested this on an actual device and indeed, it returns a constant true.

However, the thing is - it is all because you keep your phone connected to the PC and the Ethernet interface is available. Once you disconnect the phone and start the app, you will see that a False will be returned.

like image 114
Den Delimarsky Avatar answered Oct 15 '22 05:10

Den Delimarsky


It's possible that WiFi and/or Bluetooth weren't disabled. This might cause GetIsNetworkAvailable() to return true. According to this page:

While you're in Airplane mode, you can still turn your phone's Wi-Fi and Bluetooth on and off separately.

Maybe the assumption the device is making is that you probably only want to turn of Cellular access automatically, and Bluetooth/WiFi separately.

like image 21
Chris Laplante Avatar answered Oct 15 '22 06:10

Chris Laplante