0

次のコードは、Content1とContent2などの異なるコンテンツで2つの通知を送信した後、同じコンテンツを提供します。結果のアクティビティには、常にContent2のみが表示されます。その理由は何でしょうか?

public void onReceive(Context context, Intent intent) {
    abortBroadcast();

    mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon = R.drawable.icon;
    CharSequence tickerText = intent.getStringExtra("NOTIFICATION_TITLE");
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    CharSequence contentTitle = intent.getStringExtra("NOTIFICATION_TITLE");
    CharSequence contentText = intent.getStringExtra("NOTIFICATION_DETAILS");
    Intent notificationIntent = new Intent(context,CustomActivity.class);
    notificationIntent.putExtra("TITLE", contentTitle);
    notificationIntent.putExtra("DETAILS", contentText);
    //notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    mNotificationManager.notify(notifUUID.hashCode(), notification);


}
4

1 に答える 1

0

答えが出ました!修正は簡単でした - 追加しただけです: notificationIntent.setAction(String.valueOf(notifUUID.hashCode()));

インテント アクションとして設定された任意の一意の値 (タイムスタンプも機能します) が機能します。

于 2011-06-10T16:04:40.100 に答える