通知deleteIntent不起作用 [英] Notification deleteIntent does not work

查看:405
本文介绍了通知deleteIntent不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过有关similair问题的几个问题,但他们没有为我提供了解决方案。

I've read several questions concerning similair issues, but they do not provide me with the solution.

在我的Andr​​oid应用我火了一个通知(在应用程序类是具体的,这实际上是从C2DM推送事件开始)。

In my Android app I fire off a notification (in the Application class to be specific, which is actually started from a C2DM push event).

然后,我想接收意向的时候,全部清除按钮pssed的通知$ P $:

I then want to receive an Intent when the "clear all" button is pressed on the notifications:

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

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

In my NotificationDeleteReceiver.class I got the onReceive method:

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

    }
}

在我的清单文件我有:

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

但还是的onReceive不会被调用。我能是做错了什么?有没有什么聪明的方法来调试,并查看是否意图真的是发射?

But still onReceive does not get called. What could I be doing wrong? Is there any smart way to debug and see if an Intent really is fired?

我是否需要某种形式的意图过滤器,或者它应该被罚款?

Do I need some kind of intent filter or should it be fine?

任何提示的欢迎。

推荐答案

如果你想使用的意图有一个BroadcastReceiver,你应该使用<一个href="http://developer.android.com/reference/android/app/PendingIntent.html#getBroadcast%28android.content.Context,%20int,%20android.content.Intent,%20int%29"><$c$c>PendingIntent.getBroadcast而不是 PendingIntent.getService 。您可能还需要设置一个合适的意图过滤器。

If you want to use the intent with a BroadcastReceiver, you should use PendingIntent.getBroadcast instead of PendingIntent.getService. You might also need to setup an appropriate intent filter.

这篇关于通知deleteIntent不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆