无法在Xamarin.forms中使用AlaramManager启动android服务

无法在Xamarin.forms中使用AlaramManager启动android服务,android,xamarin.forms,xamarin.android,Android,Xamarin.forms,Xamarin.android,使用DependencyService调用StartBackgroundSynchService AlaramManager代码 public void StartBackgroundSynchService() { try { AlarmManager am = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService); I

使用DependencyService调用StartBackgroundSynchService

AlaramManager代码

    public void StartBackgroundSynchService()
    {
        try
        {
            AlarmManager am = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);
            Intent intentService = new Intent(Forms.Context, typeof(ReportSynchService));

            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, intentService, 0);
            am.SetRepeating(AlarmType.RtcWakeup, DateTime.Now.Millisecond, 1000, pendingIntent);
        }catch(Exception e)
        {
            System.Diagnostics.Debug.WriteLine(e.Message);
        }
     }
服务等级

public class ReportSynchService : Service
{

    public ReportSynchService()
    {
        System.Diagnostics.Debug.WriteLine("In Services Constructor");
    }
    public override IBinder OnBind(Intent intent)
    {
        System.Diagnostics.Debug.WriteLine("In Services OnBind");
        return null;
    }

    public override void OnCreate()
    {
        base.OnCreate();
        System.Diagnostics.Debug.WriteLine("In Services OnCreate");

    }


    public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        System.Diagnostics.Debug.WriteLine("In Services OnStartCommand");
        return StartCommandResult.NotSticky;
    }

}
Alaram管理器代码工作正常,但未调用服务类。
请帮助我解决此问题。

它与BroadcastReceiver正常工作,但与Service不工作它与BroadcastReceiver正常工作,但与Service不工作