AlarmManager SetRepeating doesn't work

Agg94Agg94 ESMember ✭✭

Hi all,

I'm trying to make an alarm to repeat every 10 minutes using AlarmManager. This is my code:

Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver));
PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);
AlarmManager alarmManager = (AlarmManager) Forms.Context.GetSystemService(Context.AlarmService);
alarmManager.SetRepeating(AlarmType.RtcWakeup, 0, 600000, pendingIntent);

AlarmReceiver class

[BroadcastReceiver]
public class AlarmReceiver : BroadcastReceiver
{
    public override void OnReceive (Context context, Intent intent)
    {
        //Do something every 10 minutes
    }
}

While debugging this just works perfect but, once I stop debugging and I close the application, OnReceive it is only called one time (like 2 minutes after the last call while debugging) and never again

Am I missing something?

Thanks

Tagged:

Answers

  • FlorinBirguFlorinBirgu USMember ✭✭

    Try opening your application directly from your phone. Does this still happen?

  • Agg94Agg94 ESMember ✭✭

    I have read more about this topic.

    In the question above, by closing the application I was referring to kill the application from the task manager.

    In case the application gets killed from the task manager all scheduled alarms won't work any more.

  • ThekidThekid INMember ✭✭

    I think you need to use services if you want this to work when the app is closed, i dont know the exact details still learning came across this post.

Sign In or Register to comment.