title: Calling finish() after launching another activity only works sometimes
body: <p>I have a splash screen which handles automatic login. If the user is logged in, it sends s/he directly to the main activity, through the following code:</p>
  
  <pre><code>Intent intent = new Intent(activity, MainActivity.class);
  activity.startActivity(intent);
  activity.finish();
  </code></pre>
  
  <p>Where activity is the activity to be finished (I'm not using <code>this</code> because this method is common to automatic logins, manual logins, social logins etc.)</p>
  
  <p>However about 70% of the time, the splash screen is still there after finishing the main activity. This does not occur during debugging. It looks like it happens when the login happens quickly, which is why it probably never happens during debugging (because everything becomes slow).</p>
  
  <p>Logging has helped my see that, when the problem happens <code>finish()</code> is indeed being called, but <code>onDestroy()</code> is not.</p>
  
  <p>I have tried <code>FLAG_ACTIVITY_CLEAR_TOP</code>, but it doesn't help. <code>noHistory</code> does work, but brings an unwanted finishing animation and, really, I want to know what the problem with this code is. I've always used it and don't see why it fails.</p>
  
  <p>Thanks in advance.</p>