How to completely kill/remove/delete/stop an AsyncTask

AsyncTask does not cancel process on

myAsynTask.cancel(true) 

For that you have to stop it manually.

for example you are downloading video in doInBackground(..) in while/for loop.

protected Long doInBackground(URL... urls) {

         for (int i = 0; i < count; i++) {
          // you need to break your loop on particular condition here

             if(isCancelled())
                  break;             
         }
         return totalSize;
     }

Leave a Comment