I'm working on an application where the user can download files into his device , when i press on the file , it get downloaded and pushed into the directory i created but the issue is that the notification which shows is the file is downloading or not , it is not showing , and i tried but it is not working , if anyone could help me , thank you
- This is my code
private fun downloadFileIntoDevice(){
val fileExtension = chatModel.chatItem.substringAfterLast(".")
val directory = File(Environment.getExternalStorageDirectory().path + "/jobsFolder",
UUID.randomUUID().toString().substring(0,5) + "." + fileExtension)
if(!directory.exists()){
directory.mkdir()
}
val downloadRequest = DownloadManager.Request(Uri.parse(chatModel.chatItem.substringBeforeLast(".")))
downloadRequest.setTitle("الملف")
downloadRequest.setDescription("تحميل الملف")
downloadRequest.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI
or DownloadManager.Request.NETWORK_MOBILE)
downloadRequest.setDestinationUri(directory.toUri())
downloadRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
val downloadID = downloadManager.enqueue(downloadRequest)
}
PS : I'm already giving permission to download the file in android 11 and below , the file is being saved into directory after download but the download notification not showing.