从 2 个不同的应用程序控制警报 - Android
我的 Android 应用程序开发需要帮助。
事情是这样的, 我将有两个单独的应用程序(2 个项目)。在一个应用程序中,我必须启动重复警报,而在另一个应用程序中,我必须取消在第一个应用程序中启动的相同警报。
Android 文档说,相同的挂起意图和用于启动警报的意图对象 应使用取消警报。
因此,在这种情况下,待处理的意图和用于启动警报的意图对象将属于 application1,因此我无法在 application2 中使用相同的对象,
我该如何继续?
总而言之 -
问题是,我需要从一个应用程序启动重复警报,并且必须从另一个应用程序取消相同的警报。
这能做到吗。如果是这样,怎么办?
提前致谢。
自由人
I need help in my android app development.
It goes something like this,
I will be having two separate applications (2 projects). In one application, i have to start a repeating alarm and in the other application i have to cancel the same alarm that was started in the first application.
The Android documentation says, the same pending intent and the intent object that was used to start the alarm
should be used the cancel the alarm.
So in this scenario, the pending intent and the intent object that was used to start the alarm will belong to application1 so i cannot used the same objects in application2
How do I proceed?
In summary -
The problem is, I need to start a repeating alarm from one application and i have to cancel the same alarm from another application.
Can this be done. If so, How?
Thanks in advance.
ifreeman
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事情没那么简单。只有原始活动才能取消警报。
所以我认为你可以配置自定义广播。当第二个活动需要取消警报时,它将发送此广播。第一个活动将收听广播并在收到广播后取消相应的警报。
It is not that straightforward. Only original activity can cancel the alarm.
So I think you can configure a custom broadcast. When the second activity needs to cancel an alarm it will send this broadcast. The first activity will be listening to the broadcast and cancel the appropriate alarm on receiving it.
我想你可以做到。如果通过挂起意图传递给警报的意图相同,则警报被视为相同。 Intent类的filterEquals方法定义意图是否相同。如果意图相同,则警报相同,因此您可以取消该警报。检查一次。
I guess you can do. Alarms are considered as same if intents passed to them via pending intent are same. filterEquals method of Intent class defins if intents are same or not. If intents are same then alarms are same so u can cancel that alarm. Check once.