Reputation: 10068
I've wrote a code to use a DownloadManager
in order to download some files. Now I want to do the following:
DownloadManager
notification bar and inside google play current page)Upvotes: 3
Views: 7057
Reputation: 3674
To receive a notification when the download is completed, register a Receiver to receive an ACTION_DOWNLOAD_COMPLETE
broadcast. It will include an EXTRA_DOWNLOAD_ID
extra that contains the
reference ID of the download that has completed.
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
long reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
if (myDownloadReference == reference) {
// Do something with downloaded file.
}
}
};
registerReceiver(receiver, filter);
Upvotes: 9