title: Start activity from deeplink and on back press resume from latest running activity
body: <p>I am handling deep links in my app. When a link in the email is clicked, it opens related activity in the app. On back press, it either goes back to email or home (up to intent flags i use). 
  I need it to go back to <strong>latest running</strong> activity(if the app was being used before clicking the link in email) or(else) go to first activity to restart the app.</p>
  
  <p>To be clearer: User is on <strong>activity C</strong>. Email notification comes, checks it and clicks the link inside. It opens up <strong>activity E</strong>. Here, if user back press, I want to end current task and resume <strong>activity C</strong> - if activity C task has not been killed by the system. If killed, go to <strong>activity A</strong>.</p>
  
  <p>Without intent flags, it creates a new task(second app instance) and on back press it goes back to email client.
  With NEW_TASK flag, a new tasks starts. If I use CLEAR_TASK flag with this, on back press it goes home.</p>
  
  <p>Manifest</p>
  
  <pre><code>&lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.VIEW" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
  
                  &lt;data
                      android:scheme="https"
                      android:host="www.mysite.com"
                      android:pathPattern="/mypath/*" /&gt;
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>FirstActivity</p>
  
  <pre><code>if(getIntent().getData().toString().contains("keyword")){
         //intent.setFlags(...);
         intent.putExtra("myextra", getIntent().getData().toString());
     }
      startActivity(intent);
      finish();
  </code></pre>
  
  <p>EmailResultActivity</p>
  
  <pre><code> String data = getIntent().getExtras().getString("myextra");
  </code></pre>