title: Return to previous tab when activity is destroyed
body: <p>I have 2 activities </p>
  
  <ol>
  <li>MainActivity </li>
  <li>ProjectActivity</li>
  </ol>
  
  <p>MainActivity has 3 tabs (fragments)</p>
  
  <ol>
  <li>Frag1</li>
  <li>Frag2</li>
  <li>Frag3</li>
  </ol>
  
  <p>When I go to Frag2 and click 'Add' button from action bar, ProjectActivity is started. In Project Activity when I click on 'Cancel' button I am starting MainActivity again. But now when MainActivity is started it shows Frag1. </p>
  
  <p>How can change my code to show Frag2, as user was on Frag2 previously?</p>
  
  <p>I use this simple code to start the MainActivity when cancel button is clicked.</p>
  
  <pre><code>intent = new Intent(this, MainActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
  </code></pre>