gpt4 book ai didi

android - 通知 deleteIntent 不起作用

转载 作者:可可西里 更新时间:2023-11-01 19:06:15 30 4
gpt4 key购买 nike

我已经阅读了几个关于类似问题的问题,但它们没有为我提供解决方案。

在我的 Android 应用程序中,我触发了一个通知(具体来说是在 Application 类中,它实际上是从 C2DM 推送事件开始的)。

然后我想在通知上按下“全部清除”按钮时收到一个 Intent:

notification.deleteIntent = PendingIntent.getService(this, 0, new Intent(this, NotificationDeleteReceiver.class), 0);

在我的 NotificationDeleteReceiver.class 中我得到了 onReceive 方法:

public class NotificationDeleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

}
}

在我的 list 文件中我得到了:

<receiver android:name="NotificationDeleteReceiver">
</receiver>

但是 onReceive 仍然没有被调用。我做错了什么?有什么聪明的方法可以调试并查看 Intent 是否真的被触发了?

我需要某种 Intent 过滤器还是应该没问题?

欢迎任何提示。

最佳答案

如果你想将 Intent 与 BroadcastReceiver 一起使用,你应该使用 PendingIntent.getBroadcast而不是 PendingIntent.getService。您可能还需要设置适当的 Intent 过滤器。

关于android - 通知 deleteIntent 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8811876/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com