title: How to kill tasks in android?
body: <p>I use the following snippet to kill tasks , it works perfectly fine but it doesn't kill my own app. How do i make it kill my app as well?</p>
  
  <pre><code>// kill tasks
      List&lt;String&gt; reservedPackages = new ArrayList&lt;String&gt;();
      reservedPackages.add("system");
      reservedPackages.add("com.android.launcher2");
      reservedPackages.add("com.android.inputmethod.latin");
      reservedPackages.add("com.android.phone");
      reservedPackages.add("com.android.wallpaper");
      reservedPackages.add("com.google.process.gapps");
      reservedPackages.add("android.process.acore");
      reservedPackages.add("android.process.media");
      ActivityManager am = (ActivityManager) context
              .getSystemService(Activity.ACTIVITY_SERVICE);
      List&lt;RunningAppProcessInfo&gt; listeProcessus = am
              .getRunningAppProcesses();
      for (RunningAppProcessInfo processus : listeProcessus) {
          String packageName = processus.processName.split(":")[0];
          if (!context.getPackageName().equals(packageName)
                  &amp;&amp; !reservedPackages.contains(packageName)) {
              am.restartPackage(packageName);
          }
      }
  </code></pre>