title: Android finish Activity and start another one
body: <p>I'm curious about one thing. How can I finish my current activity and start another one.</p>
  
  <p>Example :</p>
  
  <pre><code>MainActivity
      --(starts)--&gt; LoginActivity
          --(if success, starts)--&gt; SyncActivity
              --(if success start)--&gt; MainActivity (with updated data).
  </code></pre>
  
  <p>So I want when <code>SyncActivity</code> starts <code>MainActivity</code> after succesfull sync and if I press back button not to return to <code>SyncActivity</code> or any other activity opened before <code>SynActivity</code>.</p>
  
  <p>I've tried with this code :</p>
  
  <pre><code>Intent intent = new Intent(Synchronization.this, MainActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
  startActivity(intent);
  this.finish();
  </code></pre>
  
  <p>but it's not working properly. Any ideas how to get the things to work properly?</p>