7

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

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

while, I want to register the receiver in my manifest.xml instead of pragmatically, and I find out people are doing 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 whats the different between android.intent.action.DOWNLOAD_COMPLETED and DownloadManager.ACTION_DOWNLOAD_COMPLETE? why they dont use <action android:name="DownloadManager.ACTION_DOWNLOAD_COMPLETE" /> in the manifest?

Jolin
  • 1,515
  • 4
  • 21
  • 24
  • 10
    Because `ACTION_DOWNLOAD_COMPLETE` is a static string that *contains* the string `android.intent.action.DOWNLOAD_COMPLETE`, see the [docs](http://developer.android.com/reference/android/app/DownloadManager.html#ACTION_DOWNLOAD_COMPLETE) ("Constant Value"). – Lukas Knuth Feb 22 '13 at 23:33

0 Answers0