public async override void OnResume() { base.OnResume(); Plugin.Geolocator.Abstractions.Position pos; try { if (WhiteLabelConfig.LOCATION_SHOOTS_ENABLED) { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); if (status != PermissionStatus.Denied) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location)) { await LoginFuncs.ShowSnackbar(this.Activity, this.Activity.FindViewById(Resource.Id.main_content), "Location required to locate nearby shoots"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location); //Best practice to always check that the key exists if (results.ContainsKey(Permission.Location)) { status = results[Permission.Location]; } } if (status == PermissionStatus.Granted) { //var results = await CrossGeolocator.Current.GetPositionAsync(10000); //LabelGeolocation.Text = "Lat: " + results.Latitude + " Long: " + results.Longitude; hasposition = true; pos = await CrossGeolocator.Current.GetLastKnownLocationAsync(); if (pos != null) { Bootlegger.BootleggerClient.UserLocation = new Tuple <double, double>(pos.Latitude, pos.Longitude); } } else if (status != PermissionStatus.Unknown && status != PermissionStatus.Denied) { //no permissions //await DisplayAlert("Location Denied", "Can not continue, try again.", "OK"); UI.LoginFuncs.ShowError(this.Activity, new Exception("Enable location to find local shoots")); } } } catch (Exception) { //LabelGeolocation.Text = "Error: " + ex; } //await CalculateNearby(new CancellationTokenSource().Token); EventListFragment.EventUpdateDelegate del2 = Bootlegger.BootleggerClient.UpdateFeatured; nearby.SetEvents("FeaturedEvents", del2, new CancellationTokenSource().Token, EventAdapter.EventViewType.FEATURED); // try to get live position: if (hasposition) { try { pos = await CrossGeolocator.Current.GetPositionAsync(TimeSpan.FromSeconds(10)); if (pos != null) { Bootlegger.BootleggerClient.UserLocation = new Tuple <double, double>(pos.Latitude, pos.Longitude); } //await CalculateNearby(new CancellationTokenSource().Token); EventListFragment.EventUpdateDelegate del = Bootlegger.BootleggerClient.UpdateFeatured; nearby.SetEvents("FeaturedEvents", del, new CancellationTokenSource().Token, EventAdapter.EventViewType.FEATURED); } catch { //do nothing, cannot get location } } await nearby.RefreshMe(true); }