title: how to force stop all checked application from list view in android programmatically
body: <p>In below given code I want to kill (forcestop) all the checked applications but after restarting my application it's showing the name of these killed applications again.</p>
  
  <p>I really don't know if they're really killed or not. Why this is so?</p>
  
  <pre><code>kill.setOnClickListener(new OnClickListener() 
      {
        @Override
       public void onClick(View v) 
       {
  
                     //Killing selected Apps 
  
                      String savedapp;
              int code = 0;
              int count = lv.getAdapter().getCount();
  
              for (int j = 0; j &lt; count; j++)
              {
                  if (lv.isItemChecked(j))
                  {
                      Intent ints = new Intent(Intent.ACTION_MAIN, null);
                      ints.addCategory(Intent.CATEGORY_LAUNCHER);
  
                      savedapp = lv.getItemAtPosition(j).toString();
                      nm.removeAll(nm);
                      // this.l = getListView();
                      // l.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
                      PackageManager pm = getApplicationContext().getPackageManager();
  
                      List&lt;ResolveInfo&gt; intentlist = pm.queryIntentActivities(ints, PackageManager.PERMISSION_GRANTED);
  
                      ActivityManager am1 = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  
                      List&lt;RunningTaskInfo&gt; processes = am1.getRunningTasks(Integer.MAX_VALUE);
  
                      if (processes != null) 
                      {
                          for (int i = 0; i &lt; processes.size(); i++) {
                              String packageName = processes.get(i).topActivity
                                      .getPackageName();
                              RunningTaskInfo temp = processes.get(i);
                              try
                              {
                                  pName = (String) pm.getApplicationLabel(pm
                                          .getApplicationInfo(packageName,
                                                  PackageManager.GET_META_DATA));
                              } 
                              catch (NameNotFoundException e) 
                              {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              }
                          //  int f = 0;
                              if (savedapp.equals(pName)) {
                                  // finish(pm.);
                                  code = intentlist.get(i).activityInfo
                                          .hashCode();
                                  finishActivity(code);
  
                                  am1.killBackgroundProcesses(packageName);
                                  am1.restartPackage(packageName);
                                  android.os.Process.killProcess(temp.id);
  
                                  finishActivity(temp.id);
  
                                  // Toast.makeText(this, packageName,
                                  // Toast.LENGTH_SHORT).show();
                                  //f = 1;
                              } 
                              else 
                              {
                                  nm.add(pName.trim());
                              }
  
                          }
  
                      }
                  }
              }
  }
  };//kill button close
  </code></pre>