My Android App is giving error while executing

0

When I click the button the message: Android.App has stopped.

I have this code that I downloaded on the internet to do a Geolocation test. AXml:

<StackLayout Orientation="Vertical">
        <Button Text="Get GPS location"  
                         Clicked="OnButtonClicked"  
                         TextColor="Chocolate"  
                         FontSize="30"/>
        <Label Text="Longitude"  
                       FontSize="60"  
                        TextColor="BlueViolet"/>
        <Label x:Name="LogitudeLabel"  
                       FontSize="20"/>
        <Label Text="Latitude"  
                       FontSize="60"  
                        TextColor="DarkRed"/>
        <Label x:Name="LatitudeLabel"   
                       FontSize="20"/>
    </StackLayout>

and my code behind:

public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private async void OnButtonClicked(object sender, EventArgs e)
        {
            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 50;

            //var position = await locator.GetPositionAsync(timeout: TimeSpan.FromTicks(10000));
            var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000);

            LogitudeLabel.Text = position.Longitude.ToString();

            LatitudeLabel.Text = position.Latitude.ToString();

        }
    }

As it stands, it gives error in timeoutMilleseconds saying that GetPositionAsync does not have a parameter psrs timeoutMilleseconds . If I comment and uncomment the line where I parse to TimeSpan.FromTicks there I get no more error, and when I upload the App, then the android stops. I've added the access_fine_locator and access_coarse_locator in Manifest . What else should I do or what is wrong?

    
asked by anonymous 18.12.2018 / 13:35

0 answers