I have an application that alerts the user with some kind of reminders. These reminders are displayed like notifications. When the user clicks on any of these notifications it should display additional information about that alarm. This is done basically by calling an activity with a specific parameter.
This is what I do:
NotificationManager mNotificationManager = (NotificationManager) MyApplication.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.reminder2, reminder.Title, System.currentTimeMillis());
Intent notificationIntent = null;
notificationIntent = new Intent(MyApplication.getContext(), ReminderActivity.class);
notificationIntent.putExtra("idnotification", reminder.ID);
PendingIntent contentIntent = PendingIntent.getActivity(MyApplication.getContext(), reminder.ID, notificationIntent, 0 );
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.FLAG_INSISTENT;
notification.setLatestEventInfo(MyApplication.getContext(), "Reminder", reminder.Title, contentIntent);
mNotificationManager.notify(reminder.ID, notification);
This seems to work, the problem is if I click more than one time on a notification it will create a new activity instead of displaying the one that is already visible.
I tried setting flags for the PendingIntent but no luck. I tried with FLAG_CANCEL_CURRENT, FLAG_NO_CREATE, FLAG_ONE_SHOT, FLAG_UPDATE_CURRENT. The only one that is close to what I need is FLAG_ONE_SHOT, but the second time I click on it doesn't show the activity.
What else can I try? I completely run out of ideas here. Thanks