Android文件下载实现代码如下:
通过:DownloadManager
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
request.setTitle("下载");
request.setDescription("《用户协议》正在下载");
request.setVisibleInDownloadsUi(true);
File file = new File(mContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "合同.jpg");
request.setDestinationUri(Uri.fromFile(file));
file.getAbsolutePath();
DownloadManager downloadManager = (DownloadManager)mContext.getSystemService(DOWNLOAD_SERVICE);
downloadManager.enqueue(request);
如果h5和Android混合开发下载文件,js文件下载实现如下
windows.location.href = ’下载文件链接‘
|