How to completly kill/remove/delete/stop an AsyncTask in Android -
i made app downloads videos our server. issue is:
when cancel downloading call:
myasynctask.cancel(true) i noticed, myasynctask doesn't stops on calling cancel... progressdialog still goes , jumping status status showing me each time cancel , start again asynctask clicking download button, new asynctask starts... each time click download.. cancel, again download separate asynctask starts.
why myasyntask.cancle(true) not cancelling task ? don't want anymore on background. want shut down if click cancel.
how ?
e d t:
thanks gtumca-mac, , others helped me did by:
while (((count = input.read(data)) != -1) && (this.iscancelled()==false)) { total += count; publishprogress((int) (total * 100 / lenghtoffile)); output.write(data, 0, count); } thanks!!!
asynctask not cancel process on
myasyntask.cancel(true) for have stop manually.
for example downloading video in doinbackground(..) in while/for loop.
protected long doinbackground(url... urls) { (int = 0; < count; i++) { // need break loop on particular condition here if(iscancelled()) break; } return totalsize; }
Comments
Post a Comment