如何在Android上取消下载操作 [英] How to cancel the download operation on Android

查看:270
本文介绍了如何在Android上取消下载操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android平台上使用SkyDrive SDK。

When use the SkyDrive SDK on Android platform.

上传带有uploadAsync()的文件时,请尝试通过调用"operation.cancel()"取消,它可以正常工作,可以取消上传操作。

When upload file with uploadAsync(),try to cancel by Calling "operation.cancel()",it work normally,can cancel the upload operation.

但是当下载带有&downloadUnync()的文件时,尝试通过调用"operation.cancel()"取消,它工作异常,可以不取消下载操作。

But when Download file with downloadAsync(),try to cancel by Calling"operation.cancel()",it work abnormally,can not cancel the download operation.

如何在Android上取消下载操作。

How can i cancel the download operation on Android.

THanks。

推荐答案

如果在服务器开始发送响应正文后调用cancel,则取消将不会执行任何操作。这是因为此时异步操作已经结束,onDownloadCompleted方法已经被  * live *
调用(即,在live NOT windows live中直播)下载流。呼叫者此时完全控制下载操作(即,呼叫者通过调用流上的读取来继续操作)。

If cancel is called after the server started sending the response body, then cancel will not do anything. This is because at this point, the async operation is over and the onDownloadCompleted method has already been called with the *live* (i.e., live as in alive NOT windows live) download stream. The caller has total control over the download operation at this point (i.e., the caller continues the operation by calling read on the stream).

如果在服务器响应之前调用了取消使用响应主体,则不会调用onDownloadCompleted方法。这似乎是我们这边的一个错误,因为呼叫者永远不会得到通知,并且流永远不会被关闭。让我谈谈我身边的一些
的人,然后再回复你。

If cancel was called before the server responded with the response body, then the onDownloadCompleted method will not be called. This seems like a bug on our side, because the caller is never notified, and the stream is never closed. Let me talk to some people on my side about this and get back to you.

Simon


这篇关于如何在Android上取消下载操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆