0

I want an application (windows Phone 8.1) which shutdown when Airplane mode is ON, and start again when Airplane mode OFF.

For this I need event of Airplane mode ON/OFF. I did not found any API for this. Can you please tell me how to achieve in WP8.1.

Thanks in Advance.

2 Answers2

0

There is no event that I know of for AirPlane mode. You do have an event telling you when network connectivity has changed

http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487166(v=vs.105).aspx

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj835820.aspx

Ken Tucker
  • 4,126
  • 1
  • 18
  • 24
0

I'm not aware of any direct API that accesses the status of Airplane Mode directly but essentially it shuts down network availability so you could test for that using the DeviceNetworkInformation class. (It's a good idea to test this on a device but I believe this would simulate Airplane Mode)

public bool IsAirplaneMode()
{
    bool[] networks = new bool[4] { DeviceNetworkInformation.IsNetworkAvailable, DeviceNetworkInformation.IsCellularDataEnabled, DeviceNetworkInformation.IsCellularDataRoamingEnabled, DeviceNetworkInformation.IsWiFiEnabled };
    return (networks.Count(n => n) < 1);
}

If you'd like to ask the user to turn it on or off, you can do that by How to set Airplane mode in Windows Phone using C#

Amit Bhatiya
  • 2,621
  • 1
  • 12
  • 20