我正在使用下载管理器从 url 下载文件。文件下载成功。
问题
文件正在静默下载,通知区域没有通知。
下载管理器在我运行 android 6.0 的设备上显示通知(带有进度条)。在我将我的设备更新到 android 7.0 后,下载管理器不会在通知区域显示任何通知。
这是我的代码
Uri uri = Uri.parse("file://" + destination);
url = "http:....."; //Valid File URL
//Set up download manager request
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription("Downloading " + file_name);
request.setTitle("My Downloader");
request.setDestinationUri(uri); //URI is valid
//Start the download
DownloadManager manager = (DownloadManager) getContext()
.getSystemService(Context.DOWNLOAD_SERVICE);
同时添加 request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
对我的情况没有帮助。
构建信息
这是我的 Gradle 构建信息。
minSdkVersion 22
targetSdkVersion 23
compileSdkVersion 25
buildToolsVersion "25.0.2"
最佳答案
我遇到了类似的问题,文件下载成功,但在通知区域看不到进度。
问题在于通知可见性。以下行帮助我解决了它:
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
希望对您有所帮助。
关于android - 下载管理器进度在通知区域不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43808716/