hi people, my problem is that using the Geolocator in xamarin android does not let me get the coordinates of the device.
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar",
MainLauncher = true)]
public class MainActivity : Activity
{
Button btnGetCoordenadas;
TextView adressText;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.activity_main);
btnGetCoordenadas = FindViewById<Button>
(Resource.Id.get_address_button);
btnGetCoordenadas.Click += BtnGetCoordenadas_Click;
adressText = FindViewById<TextView>(Resource.Id.address_text);
}
private async void BtnGetCoordenadas_Click(object sender, EventArgs e)
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync();
adressText.Text =
position.Latitude.ToString()+"/"+position.Longitude.ToString();
}
}
That is the main code and this my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0"
package="PruebaLocation.PruebaLocation" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"
android:theme="@style/AppTheme"></application>
</manifest>