I want to do a simple app that brings me my current location, I am using Geolocator plug in to consult my location but it throw me an exception error when i call the method GetPositionAsync(), the app have permission to access location in my phone. there is my code:
try
{
if ( locator.IsGeolocationEnabled == false )
{
await App.Current.MainPage.DisplayAlert("Error", "location is not enable", "aceptar");
return;
}
if( locator.IsGeolocationAvailable == false)
{
await App.Current.MainPage.DisplayAlert("Error", "location is not aviable", "aceptar");
return;
}
var position = await locator.GetPositionAsync(TimeSpan.MaxValue);
GeoPos = position.Latitude.ToString();
}
catch (Exception ex)
{
await App.Current.MainPage.DisplayAlert("Error", ex.ToString(), "aceptar");
}
its send me to a catch exception and display this error: error message
thanks to all for your help!
The only reasonable place that an index out of range exception can occur is in some external code, as far as I can tell.
Maybe the assignment to GeoPos
has an exception causing effect...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.