The implementation results are as follows:
Because it is the notification bar, then how to pass after the click? Define a broadcast, send this broadcast when clicked, register this broadcast.
Cancel the download when you receive the broadcast. The key code is here.
Broadcastreceiver Onclickcancellistener = new Broadcastreceiver () {@Overridepublic void OnReceive (context context, Intent Intent) {if (Intent.getaction (). Equals (action_cancel_download_apk)) {//todo;;/ /App.setdownload (false);//This is the user interface manual cancellation, so will go through the activity of the OnDestroy ();//Cancel Notification mnotificationmanager.cancel (NOTIFY_ID) ; Binder.cancel (); binder.cancelnotification (); if (binder! = null && binder.iscanceled ()) {stopself ()} Callback. Onbackresult ("Cancel");}};
Demo: Punch here
Android implementation background notification bar download and can cancel the demo