I am downloading a pdf file and notification for download is visible in marshmallow but it is not Visible in Android P.
My Files downloads successfully in both Android-M and Android-P
My code is here.
public static long DownloadData (Uri uri, Context context,String dir,String fileName,String title,String discription) {
if(title==null){
title="";
}
if(discription==null){
discription="";
}
long downloadReference;
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// Create request for android download manager
downloadManager = (DownloadManager)context.getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setVisibleInDownloadsUi (true);
request.setNotificationVisibility (DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.addRequestHeader("Authorization", "Bearer " + sp.getString(SharedPreferenceKeys.PREF_AUTH_TOKEN, "Woof"));
//Setting title of request
request.setTitle(title);
//Setting description of request
request.setDescription(discription);
request.setDestinationInExternalPublicDir(
dir,fileName);
//Enqueue download and save into referenceId
downloadReference = downloadManager.enqueue(request);
return downloadReference;
}
Can anyone give solution to show Download Notification in Android P as well? thanks.