title: Setting alarm notification for Dates Arrays
body: <p>I am trying to create local notification that's declenche before a given date by 2 hours , 4 hours and at this given date. This is my code, but it doesn't work:</p>
  
  <pre><code>private void alarmnotification(String notificationid, String type, long timemills) {
      Random rand = new Random();
  
      Calendar calendar = Calendar.getInstance();
      calendar.setTimeInMillis(timemills);
  
  
  
      AlarmManager mgrAlarm = (AlarmManager)getSystemService(ALARM_SERVICE);
      ArrayList&lt;PendingIntent&gt; intentArrayd = new ArrayList&lt;PendingIntent&gt;();
  
      for(int i = 0; i &lt; 4; ++i)
      {
          long timemfills = timemills - 7200000*i ;
          Calendar calendadr = Calendar.getInstance();
          calendadr.setTimeInMillis(timemfills);
  
          Calendar calendad0r = Calendar.getInstance();
          calendad0r.setTimeInMillis(SystemClock.elapsedRealtime()+calendadr.getTimeInMillis());
  
  
          Intent intent = new Intent(getApplicationContext(), NotificationPublisher.class);
          intent.putExtra("type", type);
          intent.putExtra("notificationId", notificationid);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(Home.this, i, intent, 0);
  
          mgrAlarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, timemfills, pendingIntent);
  
          intentArrayd.add(pendingIntent);
  
  
      }
  }
  </code></pre>
  
  <p>And this is My notification Publisher Code :
  public class NotificationPublisher extends BroadcastReceiver {</p>
  
  <pre><code>public static String NOTIFICATION_ID = "notificationId";
  public static String NOTIFICATION = "type";
  private LocalBroadcastManager broadcaster;
  public void onReceive(Context context, Intent intent) {
      // Get id &amp; message from intent.
      String notificationId = intent.getStringExtra("notificationId");
      String message = intent.getStringExtra("type");
      // When notification is tapped, call MainActivity.
      Intent mainIntent = new Intent(context, Home.class);
      mainIntent.putExtra("retour", message);
      mainIntent.putExtra("element_id", notificationId);
      mainIntent.setAction(Long.toString(System.currentTimeMillis()));
      PendingIntent contentIntent = PendingIntent.getActivity(context, 0, mainIntent, 0);
  
      NotificationManager myNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
  
      // Prepare notification.
      Notification.Builder builder = new Notification.Builder(context);
      builder.setSmallIcon(R.drawable.icoapp_and)
              .setContentTitle(notificationId)
              .setContentText(message)
              .setAutoCancel(true)
              .setContentIntent(contentIntent)
              .setWhen(System.currentTimeMillis())
              .setPriority(Notification.PRIORITY_MAX)
              .setDefaults(Notification.DEFAULT_ALL);
  
      // Notify
      Random rand = new Random();
      myNotificationManager.notify(rand.nextInt(), builder.build());
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The problem is that I don't get any notifications at all. </p>