I have an app where I get daily notifications, however when I click this notification, it still stays in my status bar . I'm using the NotificationCompat class to create these notifications , in which whenever another is thrown, it even overlaps the previous one. Here is the code that generates the notification:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.mipmap.ic_launcher);
Intent intent = new Intent(context, MyActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(
context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
builder.setLargeIcon(BitmapFactory.decodeResource(
context.getResources(), R.mipmap.ic_launcher));
builder.setContentTitle("Title");
builder.setContentText("Content of notification");
NotificationManager notificationManager = (NotificationManager) context.
getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, builder.build());
How do I click the notification button to stop it from being in the status bar ?