Hi, I'm using Xamarin
and GeoLocator
to make an application with Geolocation, but it does not return the data I'm passing, and in debug, it sends me the following error:
This error only appears when I click the button that executes the method I want. Prior to this I throw no error. The first time I ran it, I activated the gps, but when I continued using it, I did not even ...
This is my code:
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace OwService {
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PageGps: ContentPage {
public PageGps() {
InitializeComponent();
btnGetLoc.Clicked += BtnGetLoc_Clickied;
}
private async void BtnGetLoc_Clickied(object sender, EventArgs e) {
await RetriveLocation();
}
private async Task RetriveLocation() {
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 10;
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10000), null, true);
txtLat.Text = "Latitude: " + position.Latitude.ToString();
txtLong.Text = "Longitude: " + position.Longitude.ToString();
}
}
}