public void start() { if (_tracking) return; var ls = (LocationManager) _context.GetSystemService(Context.LocationService); //var aproviders = ls.AllProviders.ToArray(); //var hasGPS = ls.IsProviderEnabled(LocationManager.GpsProvider); //var hasNET = ls.IsProviderEnabled(LocationManager.NetworkProvider); //if (!hasGPS || !hasNET) { //throw new Exception("Must have both GPS and Net location providers"); } _locationManager = ls; var lastLocation = _locationManager.GetLastKnownLocation(LocationManager.PassiveProvider); Location = createGeoLocation(lastLocation); var criteria = new Criteria(); criteria.Accuracy = Accuracy.Fine; criteria.AltitudeRequired = true; var providers = _locationManager.GetProviders(criteria, true).ToArray(); foreach (var provider in providers) { _locationManager.RequestLocationUpdates(provider, 1000, 5, _listener, Looper.MainLooper); } _tracking = true; }
private void locationChanged(Android.Locations.Location location) { Location = createGeoLocation(location); }