Listening Download Complete:
To receive a notification after the download is complete, you need to register a receiver to receive the Action_dowload_complete broadcast. It will contain a extra_download_id extra that contains the reference ID for the download that has been completed:
public void Funclick (view view) {String servicestring = Context.download_service;downloadmanager Downloadmanager; Downloadmanager = (Downloadmanager) getsystemservice (servicestring); Uri uri = uri.parse ("http://img00.hc360.com/it/201206/201206121034589404.jpg");D ownloadmanager.request Request = new Request (URI); request.setallowednetworktypes (Request.network_wifi); Downloadmanager.getrecommendedmaxbytesovermobile (Getapplicationcontext ()); final long myreference = Downloadmanager.enqueue (request); Intentfilter filter = new Intentfilter (downloadmanager.action_download_complete); Broadcastreceiver receiver = new Broadcastreceiver () {@Overridepublic void OnReceive (context context, Intent Intent) { Long reference = Intent.getlongextra (downloadmanager.extra_download_id,-1); if (reference = = Myreference) {// Perform some operations on the downloaded file}}};registerreceiver (receiver, filter);}
Monitor Click to download the notification bar:
Intentfilter filter = new Intentfilter (downloadmanager.action_notification_clicked); Broadcastreceiver receiver = new Broadcastreceiver () {@Overridepublic void OnReceive (context context, Intent Intent) { String extraid = downloadmanager.extra_notification_click_download_ids;long[] References = Intent.getlongarrayextra ( Extraid); for (long reference:references) {if (reference = = Myreference) {///For some operations on downloaded files}}}};registerreceiver (receiver , filter);