我正在尝试使用DownloadManager
下载文件,下载开始,但没有看到任何通知。仅在android API 27上尝试
val url="http://exmaple.com/mp4.mp4" //a fabricated url
val request = DownloadManager.Request(Uri.parse(url))
.setTitle("Dummy File")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setAllowedOverMetered(true)
.setVisibleInDownloadsUi(true)
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadManager.enqueue(request)
发布于 2019-11-28 15:59:15
问题不在于你的代码,我在尝试的时候发现了这一点。因为您尝试下载的示例URL是不允许的。
W/DownloadManager: [151] Stop requested with status BAD_REQUEST: Cleartext traffic not permitted for UID 10202: http://exmaple.com/...
尝试"https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4“示例视频,它工作得很好。
快乐编码...)
https://stackoverflow.com/questions/59083978
复制相似问题