void GPS_StatusChange() { try { if (_locationService is null) { _locationManager = (LocationManager)GetSystemService(Context.LocationService); Criteria criteriaForLocationService = new Criteria { Accuracy = Accuracy.Fine }; IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true); if (acceptableLocationProviders.Any()) { _locationManager.RequestLocationUpdates(acceptableLocationProviders.First(), 0, 0, this); } _locationService = LocationServices.GetFusedLocationProviderClient(this); var locationRequest = new LocationRequest(); locationRequest.SetInterval(180000); locationRequest.SetFastestInterval(90000); locationRequest.SetPriority(LocationRequest.PriorityHighAccuracy); _providerCallback = new FusedLocationProviderCallback(); _locationService.RequestLocationUpdates(locationRequest, _providerCallback, Looper.MyLooper()); } } catch (Exception e) { //Crashes.TrackError(e); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; UserDialogs.Init(this); FirebaseApp.InitializeApp(this); firebaseAnalytics = FirebaseAnalytics.GetInstance(this); var playAvailable = IsPlayServicesAvailable(); if (playAvailable) { new GetRemoteConfig(); Intent locIntent = new Intent(this, typeof(SaleLocationService)); StartService(locIntent); fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(this); FusedLocationProviderCallback callback = new FusedLocationProviderCallback(this); fusedLocationProviderClient.RequestLocationUpdatesAsync(callback.LocationRequest, callback); } base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); global::Xamarin.FormsMaps.Init(this, bundle); LoadApplication(new App()); #if DEBUG MocksLocation(); #endif }