|
|
|
@ -139,20 +139,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel> |
|
|
|
|
binding.llView.longSnackbar(fileName, getString(R.string.action_download)) { |
|
|
|
|
// 指定下载地址 |
|
|
|
|
val request = DownloadManager.Request(Uri.parse(url)) |
|
|
|
|
// 允许媒体扫描,根据下载的文件类型被加入相册、音乐等媒体库 |
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
|
request.allowScanningByMediaScanner() |
|
|
|
|
// 设置通知的显示类型,下载进行时和完成后显示通知 |
|
|
|
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) |
|
|
|
|
// 允许在计费流量下下载 |
|
|
|
|
request.setAllowedOverMetered(false) |
|
|
|
|
// 允许该记录在下载管理界面可见 |
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
|
request.setVisibleInDownloadsUi(false) |
|
|
|
|
// 允许漫游时下载 |
|
|
|
|
request.setAllowedOverRoaming(true) |
|
|
|
|
// 允许下载的网路类型 |
|
|
|
|
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI) |
|
|
|
|
// 设置通知 |
|
|
|
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN) |
|
|
|
|
// 设置下载文件保存的路径和文件名 |
|
|
|
|
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName) |
|
|
|
|