我已经实现了Download Manager代码,用于从服务器下载excel文件,但无法下载。
Uri uri = Uri.parse(“ http://myip/getfile?param1=value1¶m2=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);