Android 意图闹钟管理器
我正在尝试创建将使用 Alarmmanager 设置的意图。目前,我可以用一个意图来做到这一点,向其中添加额外的数据(字符串,但我将它们作为带有分隔符的一个字符串发送),并且一切正常并在正确的时间发生。然而,当我尝试发送这样的多个意图时,它们会被覆盖,并且只有一个在正确的时间发出。我如何构建我的意图,使它们看起来与警报管理器不同(我认为它们在运行 filterIntent() 时被删除)。
长话短说- putExtra() 使所有意图看起来仍然相同...我怎样才能使它们看起来不同,这样它们就不会被删除(并跟踪它们,以防我想删除特定的意图)
I am trying to create intents that will be set using alarmmanager. Currently, I can do this with one intent, add extra data to it (strings, but i send them as one string with a seperator), and everything works fine and goes off at the correct time. However, when I try to send multiple intents like this, they are overwritten and only one goes off at the correct time. How can i structure my intents so that they appear different to the alarmmanager (i think they are getting deleted when filterIntent() is run).
long story short- putExtra() makes all the intents look the same still... how can i make them look different so they wont get deleted (and keep track of them in case i want to delete a specific one)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我安排小部件更新的方式。每一个都可以是唯一的,因为它们有一个唯一的小部件 ID 号。
This is how I scheduled updates for my widgets. Each one allowed to be unique because they have a unique widget id number.
根据文档,
AlarmManager
使用filterEquals()
。查看filterEquals()
的文档,了解它如何确定两个Intent
是否相等。另外,chris324的解决方案是一个非常好的解决方案。According to the docs,
AlarmManager
checks if twoIntent
s are equivalent usingfilterEquals()
. Check out the docs forfilterEquals()
to see how it decides whether twoIntent
s are equivalent. Also, chris324's solution is a pretty good one.