我正在尝试使用DownloadManager
下载文件,下载开始,但未查看任何通知。仅在android API上尝试过27
val url="http://exmaple.com/mp4.mp4"
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)
问题不在于您的代码,我在尝试时发现了此问题。
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”示例视频效果很好。
快乐的编码...)