DownloadManager在状态栏中没有显示图标

6

我的下载管理器在状态栏中没有显示通知图标。当您打开所有通知时,通知是存在的,但状态栏中缺少图标,因此人们无法一眼看出下载已经开始。这在老设备上不是问题,只出现在运行Android 9 Pie的Android手机上。

DownloadManager.Request request = new DownloadManager.Request(Uri.parse(youtubeDataModel.getUrl()));
    request.setDescription("Downloading " + simpleFileType + "...");
    request.setTitle(fileName);
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    request.setDestinationUri(Uri.fromFile(new File(downloadLocation + "/" + fileName + "." + fileExtension)));
    DownloadManager manager = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request);

我本以为状态栏会显示一个小的下载图标,但在新设备上它并没有。

1个回答

1

尝试将请求通知可见性更改为

request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接