알림을 생성하고 응용 프로그램이 정상적으로 작동하는 Android 응용 프로그램을 개발하고 있지만 전화가 알림을 받고 다른 알림을 받으면 나중에 알림이 첫 번째 알림을 숨 깁니다 . 응용 프로그램이 많은 알림을 수신 할 때마다 모든 알림을 표시해야합니다. 나중에 하나만 표시하면 안됩니다. 어떻게 할 수 있습니까?동시에 여러 알림을 표시하는 방법
다음은 알림을 처리하는 코드입니다. 0
는 알림 ID이다 notificationManager.notify(0, notification);
마지막 줄
private static void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, Activity_SplashScreen.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
// Play default notification sound
notification.defaults |= Notification.DEFAULT_SOUND;
//notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
// Vibrate if vibrate is enabled
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(0, notification);
}