How can I turn on the GPS if fhe GPS is turn off with XAMARIN in Android system?
My devices is not rooted.
You could invoke the corresponding system dialog.
Check if GPS is available, if not, navigate to system Settings to turn it on.
protected override void OnResume()
{
base.OnResume();
checkGPSEnabled();
}
private void checkGPSEnabled()
{
LocationManager manager = GetSystemService(Context.LocationService) as LocationManager;
if (!manager.IsProviderEnabled(LocationManager.GpsProvider))
{
Intent intent = new Intent(Android.Provider.Settings.ActionLocationSourceSettings);
intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
StartActivity(intent);
}
}