I updated Android SDK TO 30 Then Issues occurred while downloading the pdf file from api.
At SDK 29
Uri uri1 = Uri.fromFile(newFile(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), ""));
Above code was working fine. After upgrading to SDK 30 following code doesn't show the downloaded file.
My Code
File direct2 = new File(getExternalFilesDir(null)+ FileUtils.DOWNLOAD_PDF_DESTINAION);
if (!direct2.exists()) {
direct2.mkdirs();
}
DownloadManager downloadManager = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
Uri uri1 = Uri.fromFile(new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), ""));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(true).setTitle(title + strDate + ".pdf")
.setDescription(description)
.setDestinationUri(uri1)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);//to show the DOWNLOAD notification when completed
} ```