Android Alarm manager is not repeating

216 Views Asked by At

My Code: (Alarm interval 24 hours)

Calendar calSet = Calendar.getInstance();
calSet.add(Calendar.DATE,-1);
calSet.set(Calendar.HOUR_OF_DAY, 10);
calSet.set(Calendar.MINUTE, 20);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);

PendingIntent pi=PendingIntent.getBroadcast(context,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);   
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,calSet.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pi);

Lets say I'm calling this function on Jan 3rd ,11:00 As per my understanding Alarm manager has to executed twice

  1. For Jan 2nd, 10:20 (As I have added calSet.add(Calendar.DATE,-1))

  2. For Jan 3rd, 10:20 (As the current time is already 11:00)

But, the Alarm manager is triggered only once. Could someone help me with this?

I even tried

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,calSet.getTimeInMillis(),24*60*60*1000,pi);

How can I make it to trigger twice at Jan 3rd, 11:00 (In this scenarion)

0

There are 0 best solutions below