2011-06-09 13 views
0

次のコードは、異なる内容の2つの通知をContent1とContent2に送信した後、同じ内容を示します。結果のアクティビティには常に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); 


} 

答えて

0

答えを得ました!修正は簡単でした - ちょうど追加されました: notificationIntent.setAction(String.valueOf(notifUUID.hashCode()));

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

関連する問題