在我的Android应用中,我正在使用通知服务(NotificationManagerCompat)。我的问题是,当我收到一个以上的通知时,我会在阴影中看到它们,但是当我将应用程序置于后台时,阴影中的所有通知都消失了。 当我的应用程序从前景移到背景时,如何防止它们消失并使其保持阴影?
这是我的代码示例:
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());