To have separate notifications, you need to use a different one IDfor each of them.
this is a simple example:
private int SIMPLE_NOTFICATION_ID_A = 0;
private int SIMPLE_NOTFICATION_ID_B = 1;
then
displayNotification("Extra for A", "This is A", "Some text for activity A", MyActivityA.class, SIMPLE_NOTFICATION_ID_A);
displayNotification("Extra for B", "This is B", "Some text for activity B", MyActivityB.class, SIMPLE_NOTFICATION_ID_B);
and displayNotification:
private void displayNotification(String extra, String contentTitle, String contentText, Class<?> cls, int id) {
Notification notifyDetails = new Notification(R.drawable.icon, "New Alert!", System.currentTimeMillis());
Intent intent = new Intent(this, cls);
intent.putExtra("extra", extra);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), id, intent, PendingIntent.FLAG_ONE_SHOT);
notifyDetails.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
mNotificationManager.notify(id, notifyDetails);
}
source
share