Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to programatically check airplane mode status?

I am creating project in which i required API to know airplane mode status on in windows phone.or any other way to know status.

like image 838
user2507707 Avatar asked Jul 05 '13 07:07

user2507707


1 Answers

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 launch the setting via ConnectionStatusTask.

like image 120
keyboardP Avatar answered Nov 16 '22 11:11

keyboardP