title: Is it possible to cancel/stop a download started using DownloadManager?
body: <p>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. </p>
  
  <p>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.</p>
  
  <p>I have the following receiver defined.</p>
  
  <pre><code>&lt;receiver 
          android:name=".DownloadStatusReceiver"
          android:exported="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.DOWNLOAD_COMPLETE" /&gt;
              &lt;action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED" /&gt;
       &lt;/intent-filter&gt;
   &lt;/receiver&gt; 
  </code></pre>
  
  <p>And in the receiver</p>
  
  <pre><code>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);
  
  }
  </code></pre>
  
  <p>Any insights?</p>