I am currently trying to have my Nexus 4 show toast notifications containing the latitude and longitude of my phone with only GPS enabled, without internet. My issue is that nothing is being displayed. I'm using the GeoLocator plugin.
Code:
using Android.App;
using Android.OS;
using Android.Widget;
using Plugin.Geolocator;
namespace Tracker {
[Activity(Label = "Tracker", MainLauncher = true, Icon = "@mipmap/icon", Theme = "@android:style/Theme.Black.NoTitleBar")]
public class MainActivity : Activity {
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
var locator = CrossGeolocator.Current;
locator.PositionChanged += (sender, e) => {
var position = e.Position;
string message = "Latitude: " + position.Latitude + " | " + "Longitude: " + position.Longitude;
Toast.MakeText(this, message, ToastLength.Long).Show();
};
}
}
}
Permissions:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />