so I'd like to know how I could remove the pending notification in the NotificationCenter after the user clicks it. Here's my BroadcastReceiver:
public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, BackgroundChecks.class);
startServiceIntent.putExtra("notificationActivityAmtsblatt", AmtsblattActivity.class.getName());
startServiceIntent.putExtra("notificationActivityAmtstafel", AmtsblattActivity.class.getName());
context.startService(startServiceIntent);
}
}
Can I put it somewhere in that BCReceiver? Thank you
The easiest solution is to set the autoCancel attribute of your notification to true when you build your notification like :
yourNotification.setAutoCancel(true);
But if you want to dismiss the notification in your BCReceiver, you can use the cancel(int notificationId) method of NotificationManager like :
NotificationManager mNotifyMgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.cancel(youNotificationId);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.