Q:

Restoring an activity stack from a notification?

I have a notification that create from an activity in a stack, and it's important that the stack be restored. Each activity in the stack should only be there a single time.
So I have this:
A -> B, B starts notification
For my intent, I need to restore A -> B on the stack. I tried starting A, but the intent didn't seem to have any extras to start startActivity immediately.
What combination of flags and XML attributes do I need to restore a stack?
If the user is on B and taps the notification, it should not start a new stack. Reloading everything is fine, but it should not go A -> B -> B.

A:

In your notification intent use
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

Since you can't/shouldn't change the back button function of backing back across different Apps. In B activity use an 'Up' button to navigate back up the stack using something like the following
Intent upIntent = new Intent(this,ParentActivity.class);
upIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(upIntent);
finish();

Intent.FLAG_ACTIVITY_REORDER_TO_FRONT will bring an existing activity to the front, else it will create it keeping the stack free from duplicated activities

