I am developing an android app where I am trying to set an alarm on daily basis.And for that I am using Calendar as
alarmCalendar.set(Calendar.DATE,taskdate);
alarmCalendar.set(Calendar.MONTH, 7);
alarmCalendar.set(Calendar.YEAR, 2013);
alarmCalendar.set(Calendar.HOUR, 11);
alarmCalendar.set(Calendar.MINUTE, 30);
alarmCalendar.set(Calendar.SECOND, 0);
I was setting the alarm using the below code.
alarmtime = alarmCalendar.getTimeInMillis();
am.setRepeating(AlarmManager.RTC_WAKEUP, alarmTime, AlarmManager.INTERVAL_DAY, pi);
The Problem with the above code is, the alarm triggers sometimes and sometimes it doesn't.
So I am trying it out in one more way. that is, Once the alarm triggers, On cancel of that alarm I am trying to set it for the next day using
am.set(AlarmManager.RTC_WAKEUP, currenttime, pendingIntent);
instead of am.setRepeating(). But now the problem is that, even though there is no looping in the code, the alarm triggers continuously on cancelling it.
Not getting where I am going wrong. Please Help.Thanks!