Starting an android Service from Xamarin forms
<p>In Visual Studio I created a new class library (Xamarin Forms) :-</p>

<p><a href="https://i.stack.imgur.com/YzQI8.jpg" rel="noreferrer">Xamarin class library</a></p>

<p>Here I added my service and gave it the most basic implementation possible for a started service (note - not a bound service. Expecting - toasts to be displayed when the application is started / stopped :-</p>

<pre><code>namespace AndroidBatteryService
{
    public class AndroidBatteryService : Service
    {

        public AndroidBatteryService()
        {

        }

        [return: GeneratedEnum]
        public override StartCommandResult OnStartCommand(Intent intent,    [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            Toast.MakeText(this, "The Battery Service was just started",  ToastLength.Long).Show();
            return base.OnStartCommand(intent, flags, startId);
        }

        public override void OnCreate()
        {
            base.OnCreate();
        }

        public override void OnDestroy()
        {
            base.OnDestroy();
            Toast.MakeText(this, "The Battery Service has been stopped",     ToastLength.Long).Show();
        }

        public override IBinder OnBind(Intent intent)
        {
            //started service, NOT a binded service - return null...
            return null;
        }
   }
}
</code></pre>

<p>In another project I am invoking this service my running the following code :-</p>

<pre><code>public void StartBatteryService()
{
    Intent intent = new Intent(Android.App.Application.Context, typeof(AndroidBatteryService.AndroidBatteryService));
    Android.App.Application.Context.StartService(intent);
}
</code></pre>

<p>The code runs (I can step over it), but the OnStartCommand method in the actual service is not run and I am expecting it to. Any ideas??</p>