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);
as
this
is your Location Listener you can see the state inonProviderEnabled (String provider)
,onProviderDisabled (String provider)
oronStatusChanged (String provider, int status, Bundle extras)
. Read this API for further Information, what each state means