Folks!
This code doesn't work on Android Oreo (but ok on older versions, I can see notifications and the DownloadManager.ACTION_DOWNLOAD_COMPLETE
broadcast message).
Kotlin
testButton.setOnClickListener {
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val uri = Uri.parse("[url for a mp3 file]")
val request = DownloadManager.Request(uri)
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
request.setAllowedOverRoaming(false)
request.setTitle("Test mp3")
request.setDescription("Wow!")
request.setVisibleInDownloadsUi(true)
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/GadgetSaint/" + "/" + "Sample" + ".mp3")
val reference = downloadManager.enqueue(request)
}