下载文件下载到外部目录时,下载manager.request.setNotification Visisibility无


DownloadManager.Request downloadRequest = new DownloadManager.Request(Uri.parse(f_url[0]));
                downloadRequest.setTitle(Application.getApplication().getString(R.string.app_name));
                downloadRequest.setDescription("Saving..");
                downloadRequest.setDestinationInExternalPublicDir(path,filename);
                downloadRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                DownloadManager manager = (DownloadManager) Application.getApplication().getSystemService(Context.DOWNLOAD_SERVICE);
                manager.enqueue(downloadRequest);

如果我将下载设置为外部目录上述代码未显示文件下载完成后的通知(正在进行中显示(。

当我评论以下代码线时,它的工作正常

//downloadRequest.setDestinationInExternalPublicDir(path,filename);

为什么会发生这种情况,并且有任何方法可以解决。

您应该在AndoroidManifest.xml中添加DOWNLOAD_WITHOUT_NOTIFICATION许可,请参阅此信息:

https://stackoverflow.com/a/33753065/3471640

最新更新