C2DM でいくつかの json メッセージを受信していますが、これまでのところ問題ありません。C2DM ペイロードから json メッセージを抽出したら、ユーザーがクリックすると、受信したメッセージを表示するアクティビティを開くという通知を作成します。
C2DM メッセージ (「テスト番号 1」メッセージなど) を初めて受信すると、通知が作成され、ユーザーがクリックするとアクティビティが正常に開始され、「テスト番号 1」というメッセージが表示されます。次に、「テスト番号 2」というテキストを含む 2 番目の C2DM メッセージを送信します。通知は作成されますが、通知をクリックするとアクティビティが開始され、2 番目のメッセージではなく「テスト番号 1」というメッセージが表示されます。
私は次のように通知を作成しています:
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 はここにあります: http://pastebin.com/tmBK7rNH
メッセージが新しいデータと値で C2DM サービスから正しく送信されていることをログで確認できますが、MessageDetailsActivity を作成して新しい情報を表示することはできません。
ありがとうございます