How to find if Location is turned on or off in settings through code.
i have this xam.plugin. geolocator.
i use this code but it is not working.
IGeolocator Locator = CrossGeolocator.Current; protected override void OnAppearing() { base.OnAppearing(); if(Locator.IsGeolocationEnabled) GetLocation(); else DisplayAlert("Location","Please Turn on The Location","OK") }
private async void GetLocation()
{
var Status = await CheckAndRequestLocationPermission();
if(Status == PermissionStatus.Granted)
{
var Location = await Geolocation.GetLocationAsync();
Locator.PositionChanged += Locator_PositionChanged;
if (!Locator.IsListening)
await Locator.StartListeningAsync(new TimeSpan(0,1,0),100);
LocationMap.IsShowingUser = true;
CenterMap(Location.Latitude, Location.Longitude); ;
}
}
`