In my android app I am using notification service (NotificationManagerCompat). My problem is when I get more then one notification, I see them in the shade, but when I put my application in the background, all the notifications in the shade disappear. How do I prevent them from disappearing, and keep them in the shade while my app is moving from the foreground to the background?
Here is my code example:
Intent pushHanlderActivityIntent = new Intent(this, PushHandlerActivity.class);
pushHanlderActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pushHanlderActivityIntent.putExtra(PUSH_BUNDLE, extras);
pushHanlderActivityIntent.putExtra(START_IN_BACKGROUND, true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, pushHanlderActivityIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_1_ID)
.setSmallIcon(R.drawable.clalit_notification)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationManagerCompat notificationManager1 = NotificationManagerCompat.from(getApplicationContext());
//show the notification in shade
int random = (int)(Math.random() * 50 + 1);
notificationManager1.notify(random,builder.build());