带有请求的Android下载管理器

时间:2019-01-05 06:58:29

标签: android android-download-manager

我已经实现了Download Manager代码,用于从服务器下载excel文件,但无法下载。

Uri uri = Uri.parse(“ http://myip/getfile?param1=value1&param2=value2”)

DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.setTitle(getString(R.string.app_name));
request.setDescription(getString(R.string.msg_wait_for_download));
request.setVisibleInDownloadsUi(true);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,
    getString(R.string.app_name)+File.separator+"statement_xyz.xls");

long refid = downloadManager.enqueue(request);

0 个答案:

没有答案