I am trying to get new data on every push notification i receive, I am passing new data with every new push notification then add this data into bundle and pass it to my activity, The issue every time when i send push notification my activity always use previous data in bundle.
Here is my code,
Intent notificationIntent = new Intent(context, Myactivity.class);
Bundle b = new Bundle();
b.putString("post_id", newsletter_key);
b.putString("newsletter_title", message);
notificationIntent.putExtra("bundle_push", b);
//notificationIntent.putExtra("NotificationMessage", newsletter_key.toString());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// set intent so it does not start a new activity
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
Any help ? Thanks in advance.
Replace PendingIntent by below Code
PendingIntent intent= PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
reference - http://developer.android.com/reference/android/app/PendingIntent.html