How to register a receiver to capture a completed download?

I checked some tutorial on how to notify the recipient when the DownloadManager has completed the download, they register the receiver pragmatically, like this

context.registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); 

while, I want to register the receiver in mine manifest.xmlinstead of the pragmatic one, and I find out that people do it like this:

<receiver 
    android:name=".DownloadReceiver"
    android:exported="true"
    android:icon="@drawable/download_icon" >
    <intent-filter>
        <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
     </intent-filter>
 </receiver> 

so what is the difference between android.intent.action.DOWNLOAD_COMPLETED and DownloadManager.ACTION_DOWNLOAD_COMPLETE ? why don't they use <action android:name="DownloadManager.ACTION_DOWNLOAD_COMPLETE" />in the manifest?

+5
source share

All Articles