so after going through several tutorials and answers all over the internet i finally was able to find to accomplish what i wanted to achieve,
i used a dependency service as one of the answers indicated here How to open setting from our application in xamarin
there are few things that were not mentioned like registering the interface in order to use it in platform specific projects.
here is the code for anyone who needs it
the Interface :
I called my Interface ILocSettings.cs
using System;
using System.Collections.Generic;
using System.Text;
[assembly: Xamarin.Forms.Dependency(typeof(DE2.ILocSettings))]
namespace DE2
{
public interface ILocSettings
{
void OpenSettings();
}
the form that has a button I called it DataEntryForm
DataEntryForm.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DE2.DataEntryForm"
>
<ContentPage.Content>
<StackLayout>
<Button x:Name="TurnLocationOn"
Text="Turn On Location"
Clicked="TurnLocationOn_OnClicked"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
then the DataEntryForm.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Plugin.pbXSettings;
using Plugin.Geolocator;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using Plugin.DeviceInfo;
using Plugin.DeviceInfo.Abstractions;
[assembly: Xamarin.Forms.Dependency(typeof(DE2.ILocSettings))]
namespace DE2
{
using Xamarin.Forms.PlatformConfiguration;
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DataEntryForm : ContentPage
{
public DataEntryForm ()
{
InitializeComponent ();
}
private async void TurnLocationOn_OnClicked(object sender, global::System.EventArgs e)
{
var myAction = await DisplayAlert("Location", "Please Turn On Location", "OK","CANCEL");
if (myAction)
{
if (Device.RuntimePlatform == global::Xamarin.Forms.Device.Android)
{
//DependencyService.Get<ISettingsService>().OpenSettings();
global::Xamarin.Forms.DependencyService.Get<global::DE2.ILocSettings>().OpenSettings();
}
else
{
DisplayAlert("Device", "You are using some other shit", "YEP");
}
}
else
{
DisplayAlert("Alert","User Denied Permission","OK");
}
//
}
}
}
Then I have this Class Placed on the Android Specific Platform LocationZ.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Locations;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Xamarin.Android;
using Xamarin.Forms;
using DE2;
using DE2.Droid;
//[assembly: Xamarin.Forms.Dependency(typeof(ILocSettings))]
//Notice the use of LocationZ in registering below instead of ILocSettings
[assembly: Xamarin.Forms.Dependency(typeof(LocationZ))]
namespace DE2.Droid
{
using System.Runtime.Remoting.Messaging;
using Android.Support.V4.View;
using Android.Support.V7.App;
using Xamarin.Forms;
using DE2;
public class LocationZ : ILocSettings
{
public void OpenSettings()
{
LocationManager LM = (LocationManager)Forms.Context.GetSystemService(Context.LocationService);
if (LM.IsProviderEnabled(LocationManager.GpsProvider)==false)
{
Context ctx = Forms.Context;
ctx.StartActivity(new Intent(Android.Provider.Settings.ActionLocationSourceSettings));
}
else
{
//this is handled in the PCL
}
}
}
}
`