Отображение нескольких уведомлений в строке состояния

Я разрабатываю приложение. Я хочу отображать несколько уведомлений в области строки состояния. Но каждый раз показывает предыдущее сообщение. Я пробовал много вещей, но это не работает, как я могу отображать несколько уведомлений в строке состояния Android.
Ниже приведен мой код:

private void Notify(String Title, String Message) 
{

          NotificationManager notificationManager =  (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
          @SuppressWarnings("deprecation")
          Notification notification = new Notification(R.drawable.ic_launcher,Title, System.currentTimeMillis());
          Log.e("NotificationManager","notify"); 
          Intent notificationIntent = new Intent(getBaseContext(), NoteEdit.class);
          notificationIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

          Log.e("NotificationManager","notificationIntent");
          PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
          notification.setLatestEventInfo(getBaseContext(), Title,Message, pendingIntent);
          notification.defaults |= Notification.DEFAULT_SOUND;
          notification.defaults |= Notification.DEFAULT_VIBRATE;
          notification.defaults |= Notification.DEFAULT_LIGHTS;
          notification.flags |= Notification.FLAG_ONGOING_EVENT;
          notificationManager.notify(NOTIFICATION_ID , notification); 

         }

    }

person user3656158    schedule 22.07.2014    source источник
comment
Просто попробуйте установить разные NOTIFICATION_ID (например, с помощью Random().nextInt()) для каждого уведомления.   -  person Gooziec    schedule 22.07.2014
comment
Есть ли особая причина, по которой вы используете устаревший метод Notification, а не Notification.Builder?   -  person Estel    schedule 22.07.2014


Ответы (1)


используйте это вместо 0, вам придется использовать переменную и увеличивать ее каждый раз

PendingIntent contentIntent = PendingIntent.getActivity(getBaseContext(),
                index++, notificationIntent,  PendingIntent.FLAG_ONE_SHOT);
person Pawan asati    schedule 22.07.2014
comment
это идентификатор уведомления, такой же, как сказал @Gooziec - person Pawan asati; 22.07.2014