If you want the notification to just return to your application in its
current state, you need to set the intent to match how it is launched:
action is main, category is launcher, and the component is the same
component you have published in your manifest for the main/launcher intent.

If you want to go somewhere else, you probably want to set the target
activity to have an empty task affinity (so it doesn't get associated with
your main task flow), and then be careful about managing he interaction
between it and your main app.  For example, if the activity launched from
the notification has a button to go into the main app, you need to decide
how all of that should work after the user hits the button: what happens to
any currently running instance of your app, what happens when the user
presses back from going into it, etc.  A common scenario would be to launch
one of the main activities of your app with NEW_TASK, so it will bring the
main app to the foreground with the new activity running on top of this.  In
this case you probably want this target activity to have
android:launchMode="singleTop" to repeatedly going to the app from the
notification activity doesn't cause multiple instances of the target
activity to stack up.

On Tue, Aug 18, 2009 at 5:51 AM, Gustav Mauer <[email protected]> wrote:

>
> Marco wrote:
> - You may be able to do what you want by having the notification start
> a
> - 'dummy' activity, which in turn brings your real activity to the
> - front.
>
> Marco, do you maybe please have sample code or something that show how
> one can restore a task like that, hopefully keeping the activity stack
> intact so that things like the back button behaves as the user would
> expect?
>
> Rick, yes, I also considered an empty intent, but for me that seems to
> miss the point of the ability of the user to click on the
> notification. I have built in some code to try to defend the
> application against crashes,  but like in your case, sometimes the
> activity stack is so messed up that a crash in inevitable.
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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