小编MyU*_*ken的帖子

使用FileOutputStream通过进度条下载Android ION

我正在尝试使用progressbar修改下载示例中的koush代码,使其写入FileOutputStream而不是File,但eclipse会给我以下错误:

对于ResponseFuture类型,方法progressHandler(new ProgressCallback(){})未定义

这是代码:

File file = new File(DownloadPath, uri.getLastPathSegment());
FileOutputStream fos = null;
try {
    fos = new FileOutputStream(file);
} catch (FileNotFoundException e1) {
    // TODO Auto-generated catch block
}

Future<FileOutputStream> downloading = Ion.with(getApplicationContext())
    .load(uri)
    .write(fos)
    .progressHandler(new ProgressCallback() { 
        @Override
        public void onProgress(int downloaded, int total) {
            // inform the progress bar of updates in progress
        }
    })
    .setCallback(new FutureCallback<FileOutputStream>() {
       @Override
        public void onCompleted(Exception e, FileOutputStream file) {
            // download done...
            // do stuff with the File or …
Run Code Online (Sandbox Code Playgroud)

android download fileoutputstream ion-koush

2
推荐指数
1
解决办法
2578
查看次数

标签 统计

android ×1

download ×1

fileoutputstream ×1

ion-koush ×1