Android通知栏点击不工作



我有以下代码使通知在C2DMReceiver.java通知栏。这个类本身扩展了BroadcastReceiver。以下代码在onReceive方法中。

    NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.ic_call;
    CharSequence text = "Match Found";
    CharSequence contentTitle = "Match";
    CharSequence contentText = received.getExtras().getString("matches");
    long when = System.currentTimeMillis();
    Intent intent = new Intent(context, C2DMReceiver.class);

    PendingIntent contentIntent =  PendingIntent.getBroadcast(context, 0, intent, 0);
    Notification notification = new Notification(icon,text,when);
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    notificationManager.notify(34, notification);

现在当我点击通知栏的通知。c2DmReceiver类的onReceive方法没有调用。

请帮…

您是否在Manifest文件中注册了C2DMReceiver ?如果你已经注册了,试着将下面一行更改为Manifest文件中相应的IntentFilter并检查。

Intent intent = new Intent(context, C2DMReceiver.class);

相关内容

  • 没有找到相关文章

最新更新