I made an application that downloads video from our server. The problem is this:
When I cancel the download, I call:
myAsyncTask.cancel(true)
I noticed that myAsyncTask does not stop when cancel is called ... my ProgressDialog is still going up, and this is like switching from status to status, showing that every time I cancel and start AsyncTask again by clicking the download button, it starts new AsyncTask ... Each time I click the Download button, then cancel, and then load a separate AsyncTask launch AsyncTask .
Why doesn't myAsynTask.cancle(true) cancel my task? I no longer want this in the background. I just want to completely close it if I click cancel.
How to do it?
ED i T:
Thanks to gtumca-MAC and others who helped me, this helped:
while (((count = input.read(data)) != -1) && (this.isCancelled()==false)) { total += count; publishProgress((int) (total * 100 / lenghtOfFile)); output.write(data, 0, count); }
Thank!!!
android android-asynctask
Adam Varhegyi Jun 04 2018-12-12T00: 00Z
source share