开发者

AsyncTask cancelling issue

I have a AsyncTask and the doInBackground method is implementing something which takes more time in general. So I am doing two Async Tasks and when the second one starts, I want to stop the first one.

Thus, if I have

@Override
protected Bitmap doInBackground(Integer... params) {
  books.download(13);
}

And the heavy part happens in the download(int) method actually.

Now, when I do cancel(true) on this task, i want the download开发者_如何学编程ing to stop. Thus I want the books.download(13) method to get interrupted.

Any way to do that?


Android does not interrupt your method, you have to do that. cancel(bool) invokes the method onCancelled(bool). If you don't implement this method, nothing happens.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜