Add either FLAG_ACTIVITY_REORDER_TO_FRONT or the combination of FLAG_ACTIVITY_SINGLE_TOP and FLAG_ACTIVITY_CLEAR_TOP as flags to your Intent. The latter finishes all other activities that might be on your back stack; the former simply brings any existing copy of the activity back to the foreground.
On Sat, Nov 26, 2011 at 4:51 AM, KK <dioxide.softw...@gmail.com> wrote: > hi All, > I'm trying to use Notification manager and Pending Intent so that whenever > the user clicks the notification the currently running activity's UI is > shown. However in the code I'm using, as shown below opens up a new instance > of the app instead of leading the user to the currently running one: > ---code snippet---- > mNotificationManager = (NotificationManager) > getSystemService(NOTIFICATION_SERVICE); > // //Add current song to notification bar > CharSequence tickerText = "Demo Alert"; > long when = System.currentTimeMillis(); > CharSequence contentTitle = "Now playing"; > CharSequence contentText = "Demo song"; > PendingIntent pendingIntent = PendingIntent.getActivity( > getApplicationContext(), 0, new Intent(this, > DemoPendingIntentActivity.class), 0); > Notification notification = new Notification( > R.drawable.ic_stat_playing, tickerText, when); > notification.setLatestEventInfo(getApplicationContext(), contentTitle, > contentText, pendingIntent); > notification.contentIntent = pendingIntent; > // Make the notification non-clearable > notification.flags = Notification.FLAG_ONGOING_EVENT; > mNotificationManager.notify(notificationId, notification); > ---code snippet---- > How do I open up the currently running activity instead of opening a new > one? Please let me know whats going wrong in the above code. Appreciate your > time. > Thanks, > KK > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en