My application generates multiple separate notifications, for eg, Notification A, Notification B, Notification C. etc...
If i tap on Notification A, the details of A will be visible, after that if i open Notification C or B, the activity still shows Notification A contents only. How to make it to update to show corresponding notification data. I'm assigning unique key for each notification.
Here is my code to generate notification
CharSequence title = title1;
CharSequence description = notes;
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Intent intent = new Intent(this.getApplicationContext(), Google_task_notification_preview.class);
intent.putExtra("CODE", key);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
this.getApplicationContext(), key, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
try
{
Drawable d = getResources().getDrawable(ic_launcher);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
getApplicationContext()).setLargeIcon(bitmap)
.setContentTitle(title)
.setContentText(description)
.setContentIntent(pendingNotificationIntent)
.setSound(soundUri);
if(priority == 0)
mBuilder.setSmallIcon(R.drawable.ic_low);
else
mBuilder.setSmallIcon(R.drawable.ic_high);
mBuilder.setWhen(timestamp);
Notification notification = mBuilder.build();
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_SOUND;
// cancel notification after click
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// show scrolling text on status bar when notification arrives
notification.tickerText = title + "\n" + description;
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(key, notification);
}
catch(SecurityException se)
{
se.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
0 comments:
Post a Comment