Trying to use DownloadManager like so
DownloadManager.Request request = new DownloadManager.Request(uri)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI)
.setAllowedOverRoaming(true)
.setDestinationInExternalFilesDir(this, null,String.valueOf(mPathAndFolder))
.setVisibleInDownloadsUi(false)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
long downloadID = downloadManager.enqueue(request);
Added the following permission in Android Manifest
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
Getting the following error at runtime
java.lang.NoSuchMethodError: android.app.DownloadManager$Request.setNotificationVisibility
Why this error? How to make DownloadManager work?