以下代码可以完美地将mp3文件下载到外部存储中,但不能下载内部存储器中的文件。许多智能手机没有外部存储。我能做什么?如果需要的话,我不知道如何在Kotlin中实现异步任务。
mywebView.setDownloadListener(object : DownloadListener {
override fun onDownloadStart(url: String, userAgent: String,
contentDisposition: String, mimetype: String,
contentLength: Long) {
val request = DownloadManager.Request(Uri.parse(url))
request.allowScanningByMediaScanner()
request.setDescription("Download file...")
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype))
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) //Notify client once download is completed!
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mimetype )
val webview = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
webview.enqueue(request)
Toast.makeText(getApplicationContext(), "Download avviato", Toast.LENGTH_LONG).show()
}
})
答案 0 :(得分:0)
目前无法测试代码,但应该类似于以下内容:
WHERE DateSole = STR_TO_DATE('11/17/2014', '%m/%d/%Y')