I have set three repeat daily alarm as  time 12:00,16:00 and 20:00. But I 
found that the first alarm would present at 11:59:34, 12:00:12 and 
12:00:56. I have checked many documents, no one gives me an answer. Please 
help me!

Here are my code:


//set PendingIntent.
Intent alarmIntent = new Intent(context, AlarmReceiver.class);
alarmIntent.putExtra("alarmType", 3);
PendingIntent pendingIntentMoring = PendingIntent.getBroadcast(context, 51, 
alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntentAfternoon = PendingIntent.getBroadcast(context, 
52, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntentEvening = PendingIntent.getBroadcast(context, 
53, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);


//clear the alarm manager before set the new alarm
managerMorning.cancel(pendingIntentMoring);
managerAfternoon.cancel(pendingIntentAfternoon);
managerEvening.cancel(pendingIntentEvening);


//set new alarm
managerMorning.setRepeating(AlarmManager.RTC_WAKEUP, 
cal1.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntentMoring);
managerAfternoon.setRepeating(AlarmManager.RTC_WAKEUP, 
cal2.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntentAfternoon);
managerEvening.setRepeating(AlarmManager.RTC_WAKEUP, 
cal3.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntentEvening);


//set Receiver 
public void onReceive(Context context, Intent intent) {
Intent myMessageintent = new Intent(context, UpDateDiaryMessage.class);
myMessageintent.putExtra("alarmType", 3);
context.startService(myMessageintent);
}


I have test it many times. I cannot get the alarm at 12:00:00, but I got 
two or three alarm around at 12:00:00. I dont know why this happened.



-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/7fb1708e-c331-4569-97bb-607bdeb918e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to