我无法使用HTTPS(https://)传输协议下载文件。使用Http(http://)时文件将被下载
val request = DownloadManager.Request(
Uri.parse(url))
val dm = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val fileName = URLUtil.guessFileName(url, contentDisposition, mimetype)
val destinationFile = File(
Environment.getExternalStorageDirectory().absolutePath + "/FileName",
fileName)
request.allowScanningByMediaScanner()
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
request.addRequestHeader("User-Agent", userAgent)
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
request.setDestinationUri(Uri.fromFile(destinationFile))
dm.enqueue(request)