【问题标题】:How to Pause Notification PendingIntent for some time[Android]如何暂停通知 PendingIntent 一段时间[Android]
【发布时间】:2012-08-29 12:15:11
【问题描述】:

在我的 android 应用程序中,当用户不在应用程序中时,我使用状态栏通知为用户提供重新启动应用程序的快捷方式。

我已经使用 android NotificationManager 实现了这个功能。

我想要实现的是一些我不希望启动 PendingIntent 的事件。
这意味着,当用户点击状态栏通知图标时,应该不会发生任何事情,因为当用户点击它时它会再次启动我的应用程序。

我们可以暂停或删除 PendingIntent 吗?

我已经使用 AlarmManager 进行了如下尝试:

AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(intent);

我还尝试将Notification.contentIntent 设置为NULL,但它也不起作用。

我应该如何实现它?

谢谢。

【问题讨论】:

  • 一开始你是怎么设置通知的?贴出代码

标签: android android-pendingintent


【解决方案1】:

是的,您可以使用您指定的方法取消 PendingIntent。您需要确保传递给cancel() 的 Intent 与原始 Intent 相同。两个 Intent 的操作、数据和类别必须完全相同相同。请参阅IntentFilter 的文档以获得更完整的说明。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-15
    • 2017-12-13
    相关资源
    最近更新 更多