Search code examples
androidnotificationsandroid-download-managerdownload-manager

Cancelling ongoing download does not remove notification


I am using Android DownloadManager, and have the ability to cancel ongoing download. This call also removes download progress from notification bar on all device I tested but from Nexus 5(running Android 5.0.1). Behavior is download is canceled but notification is not and get stuck at percentage complete when cancel was requested.

Here is how I set request object to display notification

DownloadManager.Request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

And this is the relevant log message output I see after I call

DownloadManager.remove(downloadId);

01-12 13:37:41.205      746-746/? V/NotificationService﹕ pkg=com.android.providers.downloads canInterrupt=false intercept=true
01-12 13:37:41.385   21155-7714/? W/DownloadManager﹕ [5020] Stop requested with status CANCELED: download canceled
01-12 13:37:41.385   21155-7714/? D/DownloadManager﹕ [5020] Finished with status CANCELED

Solution

  • To resolve this issue I had to call DownloadManager#remove() twice.