通过LAN使用下载管理器

时间:2018-10-23 18:32:58

标签: java android

我想使用默认的下载管理器来获取本地网络上提供的文件。我的代码如下:

Uri file = new Uri("http://<server_local_ip>/<path_to_file>");
DownloadManager.Request request = new DownloadManager.Request(file);
request.setTitle(...);
//request... other download notification settings

downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE);
long ticket = downloadManager.enqueue(request);

问题在于下载从未开始,它保持DownloadManager.STATUS_PAUSED状态,并在原因列DownloadManager.PAUSED_WAITING_FOR_NETWORK中,但是我可以使用浏览器下载文件。

我想念什么?这可能吗?

0 个答案:

没有答案