|

楼主 |
发表于 2017-8-16 10:59:03
|
显示全部楼层
请问我要暂停下载,我在插件里看到了这个方法
/**
@name cordova-plugin-file-transfer.abort
@function
@returns {void}
@description 终止文件传输
*/
private void abort(String objectId) {
final RequestContext context;
synchronized (activeRequests) {
context = activeRequests.remove(objectId);
}
if (context != null) {
// Closing the streams can block, so execute on a background thread.
cordova.getThreadPool().execute(new Runnable() {
public void run() {
synchronized (context) {
File file = context.targetFile;
if (file != null) {
file.delete();
}
// Trigger the abort callback immediately to minimize
// latency between it and abort() being called.
JSONObject error = createFileTransferError(ABORTED_ERR, context.source, context.target, null, -1, null);
context.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, error));
context.aborted = true;
if (context.connection != null) {
try {
context.connection.disconnect();
} catch (Exception e) {
Log.e(LOG_TAG, "CB-8431 Catch workaround for fatal exception", e);
}
}
}
}
});
}
}
我想知道暂停方法的那个参数我该传什么过去。 |
|