Try launching the Activity without setting the flag. Read up a bit
about Tasks and Affinity.

http://developer.android.com/guide/topics/fundamentals.html#acttask

Thanks and Regards,
Kumar Bibek

On Mar 18, 10:59 pm, Loki117 <[email protected]> wrote:
> Hey Wah check out the use of a Singleton design pattern on your
> receiver to a notification and create or display a Activity or I do
> believe there is a manifest attribute that allows for redisplay rather
> than recreate.
>
> On Mar 18, 1:37 pm, Wah <[email protected]> wrote:
>
> > Hi all:
>
> > From notification manager, how do I resume a task instead of creating
> > a new instance of it?
>
> > I want to create a link in the status bar on the phone through
> > notification manager. When I click on it, I want want a particular
> > task to come to the foreground.
>
> > However, it seems my code always launch a new task even if there is an
> > existing one running. For example, I click on the link the first time,
> > a task shows up. When I click the second time, I see an animated task
> > showing up again ... repeat that 5 times. And then when I hit "back"
> > button, the 5 instances will disappear one by one (proving it's not
> > just a single instance). Very annoying.
>
> > Code snippet:
> > ===
> >     CharSequence text = getText(R.string.my_service_started);
>
> >     // Set the icon, scrolling text and timestamp
> >     Notification notification = new Notification(R.drawable.lock,
> > text, System
> >         .currentTimeMillis());
>
> >     Intent intent = new Intent(Intent.ACTION_MAIN);
> >     intent.addCategory(Intent.CATEGORY_LAUNCHER);
> >     intent.setComponent(new ComponentName(this,
> > StartActivity.class.getName()));
> >     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
> >         | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
>
> >     PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
> > intent, 0);
>
> >     notification.setLatestEventInfo(this,
> > getText(R.string.lock_service_label),
> >         text, contentIntent);
>
> >     notificationManager.notify(R.string.lock_service_started,
> > notification);

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to