Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DownloadManager not working on android 8.0

DownloadManager does not work on Android 8.0. I don't know why. Can somebody help me?

This is what I have tried:

val downloadBroadcastReceiver = DownloadBroadcastReceiver()
context.registerReceiver(downloadBroadcastReceiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
request = DownloadManager.Request(Uri.parse(url))
val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(folder + File.separator + fileName))
request.setMimeType(mimeType)
request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, fileName)
request.setTitle(title)
request.setDescription(description)
request.setNotificationVisibility(VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
request.allowScanningByMediaScanner()
id = downloadManager.enqueue(request)
like image 816
Zheng Avatar asked Oct 20 '17 03:10

Zheng


People also ask

Why my download manager is not working?

Android Download Manager Not Working Sometimes the Android Download Manager doesn't work. Oftentimes, the files it's downloading (to a temporary location called a "cache") become corrupted. In this case, wiping the cache should fix the problem.

Do I need a download manager for Android?

If you're usually on an erratic mobile network, the chances of this happening are even higher. Hence, you need a download manager. Download managers can help you overcome several common hassles about downloading from the internet.


1 Answers

Make sure you don't have any VPN applications enabled on the phone. In my case I had an ad-blocker application hat ran as VPN on the phone that interfered with the DownloadManager.

like image 167
Nicu Surdu Avatar answered Oct 24 '22 19:10

Nicu Surdu