title: Close application and remove from recent apps/
body: <p>I know this question is common and asked many times on Stack Overflow, but after visiting nearly the four pages of search engine results and nearly the 20 question of Stack Overflow regarding this issue, I found that none of them is resolved or answered correctly.</p>
  
  <p><strong>What I want:</strong></p>
  
  <p>I want to show my app in recent apps list when it is running but when I close app then my process should be killed and application should be removed from recent apps list.</p>
  
  <p><strong>Some answers I found:</strong></p>
  
  <pre><code>use System.exit(0); //doesn't clear app from recents
  OR
  use android.os.Process.killProcess(android.os.Process.myPid()); //doesn't clear app from recents
  OR
  use finish() or this.finish() or Activity.finish();// doesn't clear app from recents
  </code></pre>
  
  <p>And one common suggestion I see in every answer that add below code in manifest:</p>
  
  <pre><code>android:excludeFromRecents //I think this is wrong approach.
  </code></pre>
  
  <p>because after adding this when user presses home button while my app is running then user cannot see my app in recent Apps List.</p>
  
  <p>And many other suggestions on this but none of them do both tasks close application and clear application from recent apps list. Also if you go in <code>Settings&gt;Apps&gt;yourApp&gt;your Application</code> see that still it asks for "force stop" means application is running!</p>