0
You’re making a mistake for me:
"Method 'Plugin.Geolocator.Abstractions.IGeolocator.Getpositionasync' not found"
In IOS version is working well, but on Android could someone give me a hint?
It’s my first app in Xamarin
using Xamarin.Forms;
using Plugin.Geolocator;
using System.Threading.Tasks;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;
namespace LocationSampleApp
{
public partial class LocationSampleAppPage : ContentPage
{
public LocationSampleAppPage()
{
InitializeComponent();
btnTeste.Clicked += BtnGetLocation_Clicked;
}
public async void BtnGetLocation_Clicked(object sender, EventArgs e)
{
await RetreiveLocation();
}
private async Task RetreiveLocation()
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled)
{
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(100));
if (position == null)
return;
txtLang.Text = "Latitude " + position.Latitude.ToString();
txtLong.Text = "Longitude " + position.Longitude.ToString();
}
else{
await DisplayAlert("Error", "Home", "OK");
}
}
}
}
Voce included the library in the android project?
– mcamara
make sure how much work with some library, the same should be installed in all projects (Portable, iOS, Android and UWP).
– mcamara
yes it is installed, in the project Locationsampleapp.Droid -> "Packeges" Xam.Plugin.Geolocator has to install and somewhere else ?
– Nagi
Do this, delete the BINS and OBJ folders of all projects then do a package store! the Xamarin is full of these details, sometimes I always need to do this when I go through this kind of problem!
– mcamara
function :D.. deletes the BINS and OBJ folders of all projects then makes a packet Restore!
– Nagi