Can not remove my activity from the Stack
<p>I know this has been asked. I browsed and tried whatever I have found but for some reason, it is not working for me.</p>

<p>my code is as follow</p>

<pre><code>runOnUiThread(new Runnable() {
@Override
public void run() {
  Intent intent = new Intent(LoginActivity.this, HomepageActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
}
</code></pre>

<p>I can not use</p>

<p>android:noHistory="true"</p>

<p>as my activity in some circumstances has to stay on the stack.</p>

<p>So, i have the following behaviour. I log in into my app with the LoginActivity, then it goes to the HomepageActivity, but if I press the Back bottom, the LoginActivity pops back again, which I do not want.</p>

<p>Any idea how I could fix this.</p>
