Reputation: 4207
I'm working on creating a 2nd service in my application, and since it does a completely different job from the 1st, I'd like them to send separate, un-related notifications. However, the 2nd notification appears to be replacing the first in my status bar.
This is the notification code from my first service that seems to be working nicely:
private void showNotification()
{
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder (this)
.setAutoCancel (true)
.setSmallIcon (R.drawable.icon)
.setWhen (System.currentTimeMillis())
.setContentTitle ("TCP Server Service Started");
TaskStackBuilder stackBuilder = TaskStackBuilder.create (this);
stackBuilder.addNextIntent (new Intent (this, Launcher.class)); // This cannot be removed
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent (0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent (resultPendingIntent);
notificationMngr.notify (0, mBuilder.build());
}
And I basically lifted that character for character and pasted it into my new service class. Are either of those magic zeroes (in getPendingIntent(), and in notify()) parameters I should experiment to separate these??
Upvotes: 1
Views: 27
Reputation: 1398
From the documentation.
If the ID remains unchanged, the existing notification is updated.
There's also a pretty good example there as well. Check here. Look for Updating Notifications.
Upvotes: 1