how to make the appliction exit when pressing back button in the main activity?
<p>In my application when i click the back button it  passes through all the  activities that i open them  previously , i  used the  public void <code>onBackPressed()</code> method to make  the back button back to the activity that i want as follow </p>

<pre><code>public void onBackPressed()
  {
    startActivity(new Intent("com.MyDiet.Main"));
    Tracker.this.finish();
  }
</code></pre>

<p>is that true and safe way to code the back button ? how i can prevent the application from passing through all the previous opened activities  when the back button is pressed ? and how i can make the application exit when i click the  back button in the main activity? </p>
