每当收到包含特定关键字的新消息时,我都会显示通知。我使用以下代码在通知区域显示通知,
String contentTitle = "V-Card Received";
String contentText = "You have reeived a new V-Card";
mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, receiveVCard.class);
notificationIntent.putExtra("sender", sender);
notificationIntent.putExtra("vCardString", messages[i].getDisplayMessageBody());
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
int icon = R.drawable.contactvcard;
CharSequence tickerText = "V-Card Received";
long when = System.currentTimeMillis();
notifyDetails = new Notification(icon, tickerText, when);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, pendingIntent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
notifyDetails.flags =Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
现在,我想在用户单击通知后删除通知。我曾经Notification.FLAG_AUTO_CANCEL
取消通知。但即使用户点击它,它也不会删除通知。当用户单击通知时,是否有其他方法可以删除通知。