Hen*_*rik 14 notifications android broadcastreceiver
我已经阅读了几个关于similair问题的问题,但是它们没有为我提供解决方案.
在我的Android应用程序中,我触发了一个通知(在Application类中是特定的,实际上是从C2DM推送事件开始的).
然后我想在通知上按下"全部清除"按钮时收到一个Intent:
notification.deleteIntent = PendingIntent.getService(this, 0, new Intent(this, NotificationDeleteReceiver.class), 0);
Run Code Online (Sandbox Code Playgroud)
在我的NotificationDeleteReceiver.class中,我得到了onReceive方法:
public class NotificationDeleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
}
}
Run Code Online (Sandbox Code Playgroud)
在我的清单文件中,我得到了:
<receiver android:name="NotificationDeleteReceiver">
</receiver>
Run Code Online (Sandbox Code Playgroud)
但仍然onReceive没有被调用.我能做错什么?是否有任何智能的方法来调试,看看Intent是否真的被解雇了?
我需要某种意图过滤器还是应该没问题?
欢迎任何提示.
kab*_*uko 12
如果要将intent与BroadcastReceiver一起使用,则应使用PendingIntent.getBroadcast而不是PendingIntent.getService.您可能还需要设置适当的intent过滤器.
| 归档时间: |
|
| 查看次数: |
4551 次 |
| 最近记录: |