【问题标题】:Android Prevent Notification if in desired Activity [duplicate]如果在需要的活动中,Android会阻止通知[重复]
【发布时间】:2012-02-23 00:24:48
【问题描述】:

可能重复:
Android: How can I get the current foreground activity (from a service)?
Optionally starting activities and using notifications from services in Android. Only launch or notify if a certain app is present

如果我在 SyncService 中获得更新时生成通知,如果我已经在使用新信息的活动中,如何防止它出现?

这有点像当你使用 gmail 应用程序时,当你在应用程序之外时会收到通知,但当你在应用程序中时却看不到它。

【问题讨论】:

标签: android notifications


【解决方案1】:

CommonsWare 为this question 提供了解决方案。

具体来说,他链接到this blog post,它解释了有序广播的使用。

作为一个不太有效的想法,您可以在您的活动和服务中实现广播接收器,然后在发送通知之前,向您的活动发送广播意图并等待响应。如果您没有收到回复,请提出通知。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2015-01-27
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    相关资源
    最近更新 更多