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);
为什么会发生这种情况,有什么方法可以解决。
答案 0 :(得分:0)
您应该在andoroidManifest.xml中添加DOWNLOAD_WITHOUT_NOTIFICATION
权限,请参阅: