title: Close android application programmatically
body: <p>How can i close my application programmatically?</p>
  
  <p>I used</p>
  
  <pre><code>   finish();
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>android.os.Process.killProcess(android.os.Process.myPid());
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>System.exit(0);
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>moveTaskToBack(true);
  </code></pre>
  
  <p>but it closed the current running activity, but i need to close the whole application??</p>
  
  <p>I need to close app to retrieve some memory and then restart application again.</p>
  
  <p>Or </p>
  
  <p>does there is a way to clear all memory of the application?</p>