I am trying to download files using the download manager and the download does not seem to be starting on Android P (running on the emulator). It works fine on Android Oreo and Android Marshmallow. Here is the code.
DownloadManager.Request downloadRequest = new DownloadManager.Request(Uri.parse(URLS.URLforDownloadingFileData(fileName)));
File file = new File(mobileInfo.getExternalFileStorageDirectory(),fileName);
downloadRequest.setDestinationUri(Uri.fromFile(file));
downloadRequest.setTitle(titleOfDownload);
downloadRequest.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
downloadManager.enqueue(downloadRequest);
Any idea why this could be happening and how to solve this problem? Anything to do with changes introduced in Android P?