如何解析日期列表并将它们设置到 AlarmManager?
我正在从 HTML 检索日期列表。
检索列表时将其设置为 List。
我想使用 SimpleDate 解析器(我知道如何做)来解析和设置 AlarmManager 的日期。
因为它是多个日期。我如何为此创建一个方法?为每个日期创建一个警报。
第一次加载日期列表时,我希望它解析日期并为每个日期设置警报。
如果一天有多个闹钟,我怎样才能将它们合并为一个?
I am retreiving a list of dates from HTML.
The list is set to a List when it is retreived.
I want to use a SimpleDate Parser(which i know how to do) to parse and set the date for the AlarmManager.
Since it is more than one Date. How could i create a method for this? To create a Alarm for each Date.
The first time the list of dates is loaded i would like it to parse the dates and set an alarm for each.
And if its more than one alarm on one day, how could i combine them as one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在包含包含日期的列表对象的大小时设置警报。
现在解析它并在任何循环(如 for 循环)中设置待处理对象的警报。
只需在 for 循环中为 Intent、PendingIntent AlarmManager 使用相同的对象,
就像这样
You can set the alarm as you contain the size of the List object which contains the date.
now parse it and set in alarm with the pending object in any loop like for loop.
just use the same object for the Intent, PendingIntent AlarmManager
in the for loop do like this way
为每个设置一个警报,这是可能的并且支持。
但是,请注意,您必须以某种方式区分警报,以便 Android 不会“覆盖”旧警报。
问题是,如果 2 个警报使用相同的意图参数和附加信息,则新警报将覆盖旧警报。
例如,您应该像这样更改 requestId 参数:
Set an alarm for each, it is possible and supported.
However, please note that you have to differentiate the alarms in such a way so that Android won't "overwrite" the old ones.
The thing is that if 2 alarms use the same intent params and extras the new one will overwrite the old one.
For example, you should change the requestId param like this: