developing daily alarm in android
Posted
by
zoza
on Stack Overflow
See other posts from Stack Overflow
or by zoza
Published on 2011-11-26T09:47:13Z
Indexed on
2011/11/26
9:51 UTC
Read the original article
Hit count: 218
I have this piece of code that fire the alarm once by setting a time and date using the TimePicker and the DatePicker in another activity. i want to modify it in a way that whenever i set a time and a date it will fire the alarm everyday at the same time. in other words i want the alarm to be fired dialy
public class M_ReminderManager {
private Context mContext;
private AlarmManager mAlarmManager;
public M_ReminderManager(Context context) {
mContext = context;
mAlarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
}
public void setReminder(Long reminderId, Calendar when) {
Intent i = new Intent(mContext, Medicines_OnAlarmReceiver.class);
i.putExtra(RemindersDbAdapter.KEY_ROWID_MEDS, (long)reminderId);
PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_ONE_SHOT);
mAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), pi);
}
}
i have tried using setRepeating function but i dont know how exactly i should set the attributes i used this line instead of the set fuction on the code but it didn't work:
mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, when.getTimeInMillis() ,AlarmManager.INTERVAL_DAY , pi);
can someone help me with it?
thanks in advance,
© Stack Overflow or respective owner