Im using DownloadManager
to save the mp4 that comes from the server. Im saving the file on storage/Emulated/0/Android/data/<packagename>/files/.Videos
. I notice that on Android 9 and android 11 is successfully downloading it. But in Android 10 failed. I tried to enclose it on try{}catch{}
method but i can't see anything on logs. I also try to add android:requestLegacyExternalStorage="true"
on my Android Manifest.xml
but the error still occurs. I also refer on this question which he/she using setDestinationUri()
but still i can't find a way. BTW, this is my snippet of the DownloadRequest
:
val path: String =
context.getExternalFilesDir(null)?.absolutePath + "/" + ".Videos"
val downloadmanager: DownloadManager =
context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val request: DownloadManager.Request = DownloadManager.Request(uri)
.setTitle(videoName)
.setDescription("Downloading")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setDestinationInExternalFilesDir(context, ".Videos", "test1.mp4")
//.setDestinationUri(Uri.fromFile(File(path, "test.mp4")))
//.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,videoName)
val downloadId = downloadmanager.enqueue(request)
All response is deeply appreciated :)
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
and<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
– Dearing