所以我想知道如何在用户点击后删除NotificationCenter中的待处理通知。这是我的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);
}
}
我可以把它放在BCReceiver的某个地方吗? 谢谢
答案 0 :(得分:1)
最简单的解决方案是在构建通知时将通知的autoCancel属性设置为true:
yourNotification.setAutoCancel(true);
但是如果要关闭BCReceiver中的通知,可以使用NotificationManager的cancel(int notificationId)方法,如:
NotificationManager mNotifyMgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.cancel(youNotificationId);