title: stop asynctask. How turn off or stop background process of another execution?
body: <p>I am creating an APK but I have a problem.
  My APK sends a GET request when it finishes.
  I have a <code>asynctask</code> class for sending a GET request periodically.
  The problem is that when I start the application again I need to kill the background processes of the previous launch.
  I put <code>uses-permission android:name="android.permission.RESTART_PACKAGES"</code> and <code>uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"</code> in the manifest.xml, and used the following code:</p>
  
  <pre><code>if (URLUtil.isValidUrl(URL_Pet_GET) &amp;&amp; URLUtil.isValidUrl(URL_Host)){
      //Get_Backgnd.cancel(true); not working  
        context.getSystemService(Context.ACTIVITY_SERVICE);
        manager.killBackgroundProcesses(String.valueOf(process.processName));
      //not working
  
      //ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
      //activityManager.restartPackage(packageName);
      //not working
  
      pet_get_backgrnd Get_Backgnd = new pet_get_backgrnd();
      Get_Backgnd.execute();  //Send GET request that I need stop on next execution of apk 
  }  
  private class pet_get_backgrnd extends AsyncTask&lt;Context, Object, Object&gt;{
      /*@Override
      protected void onPreExecute() {
          cancel(true);
      }*/ //not working
      @Override
      protected Object doInBackground(Context... params) { 
          //send Get requests
      }
  }
  </code></pre>
  
  <p>How can I cancel the execution of <code>Get_Backgnd</code> on the next execution of the APK?</p>