title: Android: Intent Flag to destroy activity and start new one
body: <p>So I have a Login Activity
  This Activity inflates a login.xml layout which has a USER_NAME and PASSWORD EditText Views, when I enter the Username and Password and click the Login Button I start a new Activity.</p>
  <p>The new Activity has a Logout button which basically just starts the previous Activity like so:</p>
  <pre><code>    Intent loginIntent = new Intent(getActivity(), Login.class);
      loginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      getActivity().startActivity(loginIntent);
  </code></pre>
  <p>According to the Android Documentation the flag does the following:</p>
  <blockquote>
  <p><a href="http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP" rel="noreferrer">http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP</a></p>
  <p>If set, and the activity being launched is already running in the
  current task, then instead of launching a new instance of that
  activity, all of the other activities on top of it will be closed and
  this Intent will be delivered to the (now on top) old activity as a
  new Intent.</p>
  </blockquote>
  <p>The problem is that the Username and Password still appear in the EditText Views after I logout, is there a Flag that destroys the Login activity and just starts a new one or is there a way to reset the fields whenever I logout? Which is the better approach?</p>