This is not working on Some Devices. In Samsung Device they not allow to download file using Download manager. I have already define permission in the manifest and also get RunTime Permission.
DownloadManager downloadManager = (DownloadManager) getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setTitle("");
request.setDescription("");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationUri(Uri.fromFile(imageFile));
request.setMimeType("*/*");
downloadManager.enqueue(request);
Use this
setDestinationInExternalFilesDir(
context.applicationContext,
Environment.DIRECTORY_DOWNLOADS,
""
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With