title: Displaying multiple notifications at user-defined times
body: <p>I've been programming in Android for over a year but have never used notifications before, which I need for one of my apps.</p>
  
  <p>In the app, there are events that can be set at different times. Obviously, the user can choose to change these times or add/remove events.</p>
  
  <p>I plan to use notifications to notify the user 5 minutes before their event starts.</p>
  
  <p>I've read through the Android developer docs for <a href="https://developer.android.com/training/notify-user/build-notification.html" rel="nofollow noreferrer">Building a Notification</a> and <a href="https://developer.android.com/guide/components/services.html" rel="nofollow noreferrer">Services</a> (which I am also new to). I have decided to use <code>Service</code>s because I figured that the notification would need to be shown even when the app not running. To help me, I have been referring to one particular <a href="https://stackoverflow.com/questions/20501225/using-service-to-run-background-and-create-notification/34207954#34207954">SO answer</a> as guidance.</p>
  
  <p>I begun by experimenting a little with the notification builder classes in my <code>NotificationService</code> class like so:</p>
  
  <pre><code>public class NotificationService extends IntentService {
  
      private static final int NOTIFICATION_ID = 1;
  
      public NotificationService() {
          super(NotificationService.class.getSimpleName());
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          showNotification();
      }
  
      private void showNotification() {
          Intent intent = new Intent(this, MainActivity.class);
  
          PendingIntent pendingIntent = PendingIntent.getActivity(
                  this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
          NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                  .setContentTitle("Test notification")
                  .setSmallIcon(R.drawable.ic_event_black_24dp)
                  .setContentText("Test description")
                  .setContentIntent(pendingIntent);
  
          NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          manager.notify(NOTIFICATION_ID, builder.build());
      }
  
  }
  </code></pre>
  
  <p>I also use the following to start this <code>Service</code> in the splash screen of my app:</p>
  
  <pre><code>Intent serviceIntent = new Intent(this, NotificationService.class);
  startService(serviceIntent);
  </code></pre>
  
  <p>To display notifications at specific times, I've read about <code>AlarmManager</code>, mainly through <a href="https://stackoverflow.com/questions/8281075/set-notification-to-specific-time">SO questions like this one</a>. I also know that to display multiple notifications, I would need different notification ids (like my constant <code>NOTIFICATION_ID</code>).</p>
  
  <p>However, what I am unsure of is dynamically updating the times that notifications would be shown each time an event is added, removed, or its times changed.</p>
  
  <p>Could someone provide me some guidance on how I could achieve this?</p>