2

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 メソッドが呼び出されていません。

助けてください...

4

1 に答える 1

2

C2DMReceiver をマニフェスト ファイルに登録しましたか? 登録済みの場合は、以下の行をマニフェスト ファイルの対応する IntentFilter に変更して確認してください。

Intent intent = new Intent(context, C2DMReceiver.class);
于 2011-04-18T13:29:07.230 に答える