title: How to kill all my activities in android?
body: <p>I am developing an Android application with few views like A,B,C,D.  Here D is my home activity. My navigation is like A->B->C->D. Once I reach Activity D, when I try to press back button, all previous activities (A,B,C) should close. I can't start activity like finish called calling new activity. Please provide me a way to kill activity of my application.</p>
  
  <p>Here I've used some code to finish all activities but did not get result.</p>
  
  <pre><code>ActivityManager manager =  (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
  List&lt;RunningAppProcessInfo&gt; list = manager.getRunningAppProcesses();
  
  if(list != null)
  {
      for(int i=0;i&lt;list.size();++i) {
          if(getApplicationContext().getPackageName().matches(list.get(i).processName)) {
              int pid = android.os.Process.getUidForName(getApplicationContext().getPackageName());
              android.os.Process.killProcess(pid);
          } 
          else {
              debug.log("app not killed");
          }
      }
  }
  </code></pre>
  
  <p>So please suggest me proper way to close all my activity at a time.</p>
  
  <p>Thanks in advace</p>