title: Set Alarm To Alert 5 Minutes Before a certian Time
body: <p>I'm trying to get Alarm Manager to alert the user 5 minutes before an event happens. How do I go about doing this?</p>
  
  <p>For example, the time of the event is 10:00:00 and I need set the alarm 5 minutes earlier at 9:55:00. I wasn't able to find examples of this in my search. </p>
  
  <p>Is there a date or calendar function that can set an earlier time based on a date?</p>
  
  <p>Below is  the incomplete pseudo code</p>
  
  <pre><code>                            int index = eventTime.indexOf(':');
                  String Hour =eventTime.substring(0, index);
                  String Min = eventTime.substring(index + 1, index + 3);
  
                  Calendar cal = Calendar.getInstance(); 
                  int em = Integer.parseInt(eventMonth);
                  int ed = Integer.parseInt(eventDay);
                  int ey = Integer.parseInt(eventYear);
                  int h = Integer.parseInt(Hour);
                  int m = Integer.parseInt(Min);
  
                          int alertTime=5;
                          m=m+alertTime;
  
                              cal.set(Calendar.MONTH, em);
                  cal.set(Calendar.YEAR, ey);
                  cal.set(Calendar.DAY_OF_MONTH, ed);
                  cal.set(Calendar.HOUR_OF_DAY, h);
                  cal.set(Calendar.MINUTE, m);
  
                              AlarmManager mgr = new AlarmManager();
  
                               mgr.addAlarm(cal.getTime(), new AlarmListener() {
              // public void handleAlarm(AlarmEntry entry)
              Log.v("calander", cal.toString());
              // }
              // });
  </code></pre>