我可以通过点击通知删除此通知吗?如何在点击通知时删除通知android
当使用setAutoCancel(true)单击此通知时,我可以取消通知。
但点击通知后不清楚通知。
private void sendNotification(String msg, Bundle extras) {
notificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent;
if (extras != null) {
intent = new Intent(this, MessageConversationActivity.class);
intent.putExtra("sender_id", extras.get("sender_id").toString());
intent.putExtra("receiver_id", Application.ACTIVE_USER.getUser_id());
intent.putExtra("gender", extras.get("gender").toString());
intent.putExtra("profile_picture", extras.get("profile_picture")
.toString());
intent.putExtra("username", extras.get("username").toString());
} else {
intent = new Intent(this, MainActivity.class);
}
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, 0);
String app_name = getString(R.string.app_name);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
this).setSmallIcon(R.drawable.app_icon)
.setContentTitle(app_name)
.setAutoCancel(true)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
builder.setContentIntent(contentIntent);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}