Android: LocationManager when Airplane mode on

1.7k views Asked by At

I am testing the location part of my app with various configurations. In AirPlane mode I don't get any message sent to ILocationListener, good or bad, from the following LocationManager on an Android 2.2. In this case the bestProvider is "network".

How can I determine if there simply is no way to get a location so that I can inform the user? When there is a network or GPS it all works fine.

The code I use (Mono for Android C#) is:

            var cr = new Criteria ();
            cr.Accuracy = Accuracy.Coarse;
            cr.PowerRequirement = Power.Low;
            cr.AltitudeRequired = false;
            cr.BearingRequired = false;
            cr.SpeedRequired = false;
            cr.CostAllowed = true;
            string serviceString = Context.LocationService;
            locationManager = (LocationManager)GetSystemService (serviceString);
            var bestProvider = locationManager.GetBestProvider (cr, false);
            locationManager.RequestLocationUpdates (bestProvider, 5000, 500f, this);
2

There are 2 answers

0
Rafael T On BEST ANSWER

as this is your Location Listener you can see the state in onProviderEnabled (String provider), onProviderDisabled (String provider) or onStatusChanged (String provider, int status, Bundle extras). Read this API for further Information, what each state means

4
Lucifer On

You can not use any kind of Communication like GPS,GPRS in AirPlane Mode. Airplane mode is a setting available on most cell phones, smartphones and other electronic devices that, when engaged, suspends many of the device's signal transmitting functions – thereby disabling the device's capacity to place or receive calls or text messages – while still permitting use of other functions that do not require signal transmission (e.g., games, built-in camera, MP3 player).