3

I have implemented DownloadManager in an activity. Download works fine. But this class will automatically create a notification which stays in status bar. Is there a way to remove this notification. Below is the code:

 Uri uri = Uri.parse(url);
    DownloadManager.Request request = new DownloadManager.Request(uri);
    request.setTitle(fileName);
    request.setDescription(fileName);
    request.setVisibleInDownloadsUi(false);
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);

    firmwareZipPath = new File(Environment.getExternalStorageDirectory()
            + File.separator
            + Constants.TEST,
            type + ".tgz");

    request.setDestinationUri(Uri.fromFile(firmwareZipPath));
    downloadId = downloadManager.enqueue(request);

I tried giving false to request.setVisibleInDownloadsUi. Still the notification is shown.

madhuri H R
  • 699
  • 1
  • 10
  • 26

1 Answers1

3

From official doc:

If set to VISIBILITY_HIDDEN, this requires the permission android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.

So you need to add permission to AndroidManifest.xml:

<uses-permission
        android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

For more information check official doc

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104