title: How to handle multiple notifications Android
body: <p>I'm developing an application where user can add events and then notify them when the event is about to happen. I know notifications should have unique IDs but how am I gonna implement it on my app? Any suggestions? Or any tutorials that you know would help me. Thanks.</p>
  
  <p>This is what I've tried so far:</p>
  
  <pre><code>public class CalendarEvent extends Activity {
  
  TimePicker time;
  DatePicker date;
  EditText title, description;
  
  int notifID;
  
  private int year;
  private int month;
  private int day;
  
  private int hour;
  private int minute;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.clendar);
  
      //---Button view---
      Button btnOpen = ( Button ) findViewById( R.id.btEventDone );
      btnOpen.setOnClickListener( new View.OnClickListener() {
  
          public void onClick(View v) {                
              time = ( TimePicker ) findViewById( R.id.tpEventTime );
              date = ( DatePicker ) findViewById( R.id.dpEventDate );      
              title = ( EditText ) findViewById ( R.id.etEventTitle );
              description = ( EditText ) findViewById ( R.id.etEventDescription );
  
              //---use the AlarmManager to trigger an alarm---
              AlarmManager alarmManager = ( AlarmManager ) getSystemService( ALARM_SERVICE );                 
  
              //---get current date and time---
              Calendar calendar = Calendar.getInstance();       
  
              //---sets the time for the alarm to trigger---
              calendar.set( Calendar.YEAR, date.getYear() );
              calendar.set( Calendar.MONTH, date.getMonth() );
              calendar.set( Calendar.DAY_OF_MONTH, date.getDayOfMonth() );                 
              calendar.set( Calendar.HOUR_OF_DAY, time.getCurrentHour() );
              calendar.set( Calendar.MINUTE, time.getCurrentMinute() );
              calendar.set( Calendar.SECOND, 0 );
  
              //---PendingIntent to launch activity when the alarm triggers---                    
              Intent i = new Intent( CalendarEvent.this, DisplayNotification.class );
  
              year = calendar.get( Calendar.YEAR );
              month = calendar.get( Calendar.MONTH );
              day = calendar.get( Calendar.DAY_OF_MONTH );
  
              hour = calendar.get( Calendar.HOUR );
              minute = calendar.get( Calendar.MINUTE );
  
              String strTitle = title.getText().toString();
              String strDescription = description.getText().toString();
              String strDate = String.valueOf( month ) + "-" + String.valueOf( day ) + "-" + String.valueOf( year );
  
  
              StringBuilder sb = new StringBuilder();
              if(hour&gt;=12){                      
                sb.append(hour-12).append( ":" ).append(minute).append(" PM");
              }else{
                sb.append(hour).append( ":" ).append(minute).append(" AM");
              }
              String strTime = sb.toString();
  
              //---assign an ID of 1---
              i.putExtra( "NotifID", notifID ); 
              i.putExtra( "Title", strTitle );
              i.putExtra( "Description", strDescription );
              i.putExtra( "Date", strDate  );
              i.putExtra( "Time", strTime );
  
              PendingIntent displayIntent = PendingIntent.getActivity(
                  getBaseContext(), 0, i, 0 );               
  
              //---sets the alarm to trigger---
              alarmManager.set( AlarmManager.RTC_WAKEUP, 
                  calendar.getTimeInMillis(), displayIntent );
              finish();
          }
      }); 
  
  }
  </code></pre>