指定时间的报警服务
我需要根据DB中的时间值提示警报。我经历了很多例子,但让我感到困惑。任何机构都可以帮助设置给定时间的重复闹钟,例如 2011-07-03 02:00:00:000 。并且应该以 5 分钟的间隔重复。
I need to prompt alarm according to the time values in DB. I came through lot of examples but confusing me. Could any body help to set a repeating alarm for given time like 2011-07-03 02:00:00:000 . and it should repeat for 5mints interval.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议你创建一个服务。该服务可以使用 AlarmManager 类读取数据库并设置警报。您可以根据您的用途使用 AlarmManager 的 set() 或 setRepeating() 方法。 http:// /developer.android.com/reference/android/app/AlarmManager.html#set%28int,%20long,%20android.app.PendingIntent%29
这是 AlarmManager 的示例 用法。
YourAlarmReceiver 类(通常)可以是一个 BroadcastReceiver,您的逻辑将在警报触发时发生。
I suggest you create a service. The service can read the database and set the alarm using AlarmManager class. You can use the AlarmManager's set() or setRepeating() methods based on your use. http://developer.android.com/reference/android/app/AlarmManager.html#set%28int,%20long,%20android.app.PendingIntent%29
here is a sample of AlarmManager usage.
YourAlarmReceiver class (usually) can be a BroadcastReceiver where your logic goes on what happens when the alarm is triggered.
日历应用程序没有公共 API
,但由于它是 Google 日历的本机 UI,因此您可以通过其 GData API 将事件推送到 Google 日历。您可以使用 AlarmManager 类
There is no public API for the Calendar application
, though since it is a native UI for a Google Calendar, you could push an event over to the Google Calendar via its GData API.You can use AlarmManager class