Search code examples
androiddeep-linkingback-stack

Generate back stack for deep linking from an email URL


I basically try to mix these two tutorials:

What I want to do is to launch a specific activity of my app when the user click on a url in an email. When the activity is launched I want the user to be able to press back and to go to the parent activity like if the user had land on this page following the normal journey throw the app.

I know how to open the specific activity but I don't know how to generate the backstack. In the example they are able to manage the backstack as the deep linking comes from a notification generated by the app itself, so they can create a pending intent. In my case the link is from an email so I can't do that.

Any idea?


Solution

  • Create activity without content view for handling incoming intents. This RouterActivity handles intents and decides what activities should be started with startActivities (TaskStackBuilder) after that it finishes itself with finish().

    RouterActivity should use theme: @android:style/Theme.NoDisplay (use Activity instead of AppCompatActivity) and should not set any content view so user will have no clue that there was any activity started before desired one.