I am using DownloadManager to download a bunch of files in my application. I am not able to figure out how to cancel the downloads which has been enqueued by downloadManager.

There are two possibilities: a. User can manually cancel it say by clicking it in the notification bar. b. Cancel and remove the download through code.

I have the following receiver defined.

<receiver 
        android:name=".DownloadStatusReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
            <action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" />
     </intent-filter>
 </receiver> 

And in the receiver

if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action)) {

    Constants.showLog(TAG, "Notification clicked");
    long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
    DownloadManager dm =(DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);             
    dm.remove(downloadId);

}

Any insights?

Edit
Report