Hi!

My app is having an Activity, and a local Service. The Service shows
notifications for time to time, and I like to open the Activity when the
notification is tapped. Now the problem is, I may get multiple activies
stacked if I tap the notifications many times in a row. Here's how I show
the notification:

final NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);

Notification notification = new Notification(R.drawable.icon, "Hello",
System
                .currentTimeMillis());

notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_NO_CLEAR;

Intent intent = new Intent(this, MyActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
PendingIntent i = PendingIntent.getActivity(this, 0, intent, 0);

notification.setLatestEventInfo(this, "Hello", "Hello", i);

notificationManager.notify(NOTIFICATION_ID, notification);

Any suggestions how to just bring the Activity to the front if it already
exists?

Br,
Antti

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to