在列表视图+进度/暂停/恢复安卓多个文件的下载管理器 [英] Multiple file download manager in listview +progress/pause/resume android

查看:355
本文介绍了在列表视图+进度/暂停/恢复安卓多个文件的下载管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个动态的下载管理我的这种形式的应用程序:

i need to make a dynamic download manager for my app in this form :

  1. 在添加新的链接到当前目录
  2. 可以暂停和恢复下载
  3. 删除完全下载从自定义列表

  1. adding new link to current list
  2. can pause and resume download
  3. deleting complete downloads from custom list

这样的

like this

起初,我用的本网站code 线程下载。

at first i use this site code for thread downloading.

那么,我做一个自定义列表视图中的下载按钮每次用户点击,该下载链接将被添加。

then , i make a custom list view that Every time user click on the Download button,that download link Will be added.

不过,我有两个问题:

  1. 在添加新的链接列表之后,所有的名单都将是新的!
  2. 太,previous未完成的下载(S)将是新的,因为列表将是新的!

现在的问题是: 我怎么可以让一个动态的下载管理我的应用程序,可以添加新的链接,列出与暂停/恢复能力,并从自定义列表中删除已下载的项目?

Now , The question is: how i can make a dynamic download manager for my app that , can adding new link to list with pause/resume ability and remove downloaded item from custom list?

编辑 - 添加定制列表视图

我的自定义列表视图在此链接: https://github.com/saeid-pm /定制列表视图

my custom list-view in this link : https://github.com/saeid-pm/Custom-Listview

推荐答案

最后经过约1年(:D),这是最好的解决方案之一:

finally after about 1years(:D) this is one of best solutions :

使用这个库通过添加使用库项目,

using this library by add to project with library ,

或与Android工作室的依赖关系:

or with Android Studio dependencies :

 dependencies {
    compile 'com.mani:thindownloadmanager:1.0.0'
 }

这是最好的,快(有)文件下载库之一,太是一件容易的使用和定制。

it's one of best and fast (any) file Download library , Too is so simple to use and customize.

例如在我的问题(1年前)的我想有多个文件,下载,放心可以指定线程池的大小:

for example in my question(in 1 year ago) that i wanted to have Multiple-File-Download , at ease can specify thread pool size by :

ThinDownloadManager downloadManager = new ThinDownloadManager(DOWNLOAD_THREAD_POOL_SIZE); 

//DOWNLOAD_THREAD_POOL_SIZE = number of threads.

古德勒克!

修改的答案@Bhuvi,(设定的目的地下载的文件)

  1. 定义文件目标:

  1. Define file destination :

        String fileName ="file name";
        File root = android.os.Environment.getExternalStorageDirectory();
        File dir = new File(root.getAbsolutePath() +`subfolder name`);

        if (dir.exists() == false) {
            dir.mkdirs();
        }

        final Uri destinationUri = Uri.parse(dir + fileName);

  • 然后 setDestinationURI (路径)的 ThinDownloadManager

  • then setDestinationURI(your path) for ThinDownloadManager

    downloadRequest = 
      new DownloadRequest(downloadUri)setDestinationURI(destinationUri).setPriority(DownloadRequest.Priority.HIGH)
    

  • 这篇关于在列表视图+进度/暂停/恢复安卓多个文件的下载管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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