【问题标题】:DownloadManager.Request.setNotificationVisibility not working properly when downloading file to external directory将文件下载到外部目录时,DownloadManager.Request.setNotificationVisibility 无法正常工作
【发布时间】:2017-11-23 20:46:30
【问题描述】:
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);

为什么会发生这种情况,有什么办法可以解决。

【问题讨论】:

  • 你有没有解决办法?

标签: android notifications android-download-manager


【解决方案1】:

你应该在 andoroidManifest.xml 中添加DOWNLOAD_WITHOUT_NOTIFICATION 权限,请看这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多