Multiple notifications to the same activity

前端 未结 1 1991
青春惊慌失措
青春惊慌失措 2020-12-01 04:43

I have an activity that is being opened from the notification bar, but when I do NotificationManager.notify(...), I\'m giving to the intent a different bundle,

相关标签:
1条回答
  • 2020-12-01 04:58

    If the PendingIntent has the same operation, action, data, categories, components, and flags it will be replaced.

    Depending on the situation i usually solve this by providing a unique request code either as static values (0,1,2) or the row id of the data I'm receiving from the DB.

    PendingIntent.getActivity(context, MY_UNIQUE_VALUE , notificationIntent, PendingIntent.FLAG_ONE_SHOT);
    

    Then I use the same unique value for notify() as

    mNotificationManager.notify(MY_UNIQUE_VALUE, notification);
    
    0 讨论(0)
提交回复
热议问题