- Use full package name for you receiver like
com.example.DownloadListenerService
- Add
android:exported="true"
BroadcastReceiver
can receive messages from sourcesoutside
its application. -
Change the name of the
Action
in theintent-filter
toandroid.intent.action.DOWNLOAD_COMPLETE
<receiver android:name="com.example.DownloadListenerService" android:exported="true" > <intent-filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> </intent-filter> </receiver> <uses-permission android:name="android.permission.INTERNET" />
The receiver only will be triggered if was registered from your application using registerReceiver(@Nullable BroadcastReceiver receiver,IntentFilter filter);
Code to enqueue Download :
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse("https://www.google.com/images/srpr/logo4w.png"));
dm.enqueue(request);