0

我正在制作一个药物提醒应用程序,提醒人们在预定的日期时间服药。

例如,如果我的开始日期是 2013 年 4 月 8 日,结束日期是 2013 年 4 月 12 日,时间是上午 11.30,那么警报应该会一直触发到 2013 年 4 月 12 日上午 11.30。 请帮助我如何实现这一目标。我知道如何设置警报管理器并触发正常警报。但是当我当时有一个开始日期和结束日期时,我对如何使用该alarmManager.setRepeating()方法感到困惑。

4

2 回答 2

0

此代码用于每天重复警报

Date dateobj=new Date(Year,month,day,hour,min);             
setRepeating(AlarmManager.RTC_WAKEUP, dateobj.getTime(), (24*60*60*1000), pendingIntent);
于 2013-04-08T09:59:51.420 回答
0

你可以通过使用 setReapting() 方法在你想要的时间设置闹钟来做到这一点。

1.Use a table to insert your entries.
2.query the table for every minute or for the time interval you want using a broadcast receiver.
3.In the onReceive() callback compare the current time with the insert time and fire the alarm.
4.if there is no record then cancel the pending intent.

如果您对此有任何疑问,请通过此链接

.

于 2013-04-08T10:08:06.687 回答