Android N在下载管理器通知中新增了一个取消按钮。
我想在我的应用程序中执行一些代码,以便在用户按下此按钮时停止进度条。如果有任何方法被调用,请告诉我是哪个方法。
请注意,Intent过滤操作DownloadManager.ACTION_NOTIFICATION_CLICKED仅在用户单击通知本身时触发,而不是在单击取消按钮时触发。
if_downloadManager = new IntentFilter();
if_downloadManager.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
if_downloadManager.addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED);
br_downloadManager = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
....
}
if (DownloadManager.ACTION_NOTIFICATION_CLICKED.equals(action)) {
// This code is not executed when the user presses the Cancel Button in the Download Manager Notification
}
}
};
提前感谢。