I am receiving some json messages with C2DM, so far this is good. Having the json message extracted from the C2DM payload, I create a notification that upon user click will open an activity that will display the message received.
The first time the C2DM message is received (for example, "test number 1" message), the notification is created and the activity starts successfully when the user clicks it and I can see the message "test number 1". Then I send a second C2DM message, with the text "test number 2", the notification is created but when I click in the notification, the activity starts I see "test number 1" message, instead of the second message.
I am creating my notification like this:
public static void createMessageNotification(Context context, Message msg) {
int icon = R.drawable.ic_stat_notify_msg; // icon from resources
CharSequence tickerText = "You've got a new message"; // ticker-text
long when = System.currentTimeMillis(); // notification time
CharSequence contentTitle = "Service Message"; // message title
CharSequence contentText = "New message";
Intent notificationIntent = new Intent(Intent.ACTION_MAIN);
notificationIntent.setClass(context, MessageDetailsActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Bundle b = new Bundle();
b.putSerializable("message", msg);
notificationIntent.putExtras(b);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
long[] vibrate = {0,100,200,300};
notification.vibrate = vibrate;
notification.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(AppUtil.getNextPushIndexMessage(), notification);
}
MessageDetailsActivity.java can be found here: http://pastebin.com/tmBK7rNH
I see in the logs that the message is coming from the C2DM service correctly, with new data and values, but I cant make the MessageDetailsActivity to display the new information.
Thank you T