title: android set multiple alarms simultaneosuly
body: <p>Ok, let me modify the question and make it much easier. I Hope you'll be able to get me the solution for this. Both the alarms should be scheduled simultaneously, which is not happening here. I am even using unique requestcode for the pending intent. <strong>HELP ME please.....</strong></p>
  
  <blockquote>
    <p>//On click Listener  </p>
  </blockquote>
  
  <pre><code>private OnClickListener mOneShotListener = new OnClickListener() {
      public void onClick(View v) {
  
          Intent intent = new Intent(AlarmController.this, OneShotAlarm.class);
          PendingIntent sender = PendingIntent.getBroadcast(AlarmController.this,0, intent, 0);
          //I even tried sender = PendingIntent.getBroadcast(AlarmController.this,0, intent, PendinIntent.FLAG_UPDATE_CURRENT);
  
  
          //the alarm to go off 30 seconds from now.
  
          Calendar calendar = Calendar.getInstance();
          calendar.setTimeInMillis(System.currentTimeMillis());
          calendar.add(Calendar.SECOND, 30);
  
          // Schedule the alarm!
  
          AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
          am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
  
          //adds 2 minutes to the time
  
          calendar.add(Calendar.MINUTE, 2);
  
          sender = PendingIntent.getBroadcast(AlarmController.this,1, intent,0);
          am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender2);
      }
  };
  </code></pre>
  
  <p><strong>OLD Question:</strong><br>
  I want to set two alarms at the same time for two different operations to be performed.</p>
  
  <p>For Eg. A user sets alarm at 2'O clock and sets the duration to 15 mins. The first alarm should fire at 2'O clock which performs function1 and the second alarm should fire at 2:15 as the user specified the duration as 15 mins which performs the function2. This operation should be repeated everyday at 2'O clock unless the user changes the time.</p>
  
  <p>I am calling this both functions on button click:</p>
  
  <blockquote>
    <p>On Click Event</p>
  </blockquote>
  
  <pre><code>saveButton.setOnClickListener(new View.OnClickListener() {  
      public void onClick(View view) {  
          ..........  
          ..........  
          new ReminderManager(this).setReminder(mRowId, mCalendar);  
          new ReminderManager(this).wakeReminder(mRowId, mCalendar, duration);  
          }  
      }
  </code></pre>
  
  <p>The setReminder contains  </p>
  
  <blockquote>
    <p>//sets alarm at 2'O clock  </p>
  </blockquote>
  
  <pre><code>public void setReminder(Long taskId, Calendar when, String duration){  
      Intent i = new Intent(mContext, OnAlarmReceiver.class);
      i.putExtra(RemindersDbAdapter.KEY_ROWID, (long)taskId);    
      PendingIntent pi = PendingIntent.getBroadcast(mContext,(int)System.currentTimeMillis(), i, PendingIntent.FLAG_UPDATE_CURRENT);    
      mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pi);    
  }
  </code></pre>
  
  <p>The wakeReminder contains</p>
  
  <blockquote>
    <p>//adds duration i.e. 15mins</p>
  </blockquote>
  
  <pre><code>public void wakeReminder(Long taskId, Calendar when, String duration){
      Intent i = new Intent(mContext, OnAlarmReceiverWake.class);
      i.putExtra(RemindersDbAdapter.KEY_ROWID, (long)taskId);
          Long d = Long.parseLong(duration);
          Long mins = d*60*100; 
          Long milli = when.getTimeInMillis() + mins;
          PendingIntent  pi = PendingIntent.getBroadcast(mContext, (int)System.currentTimeMillis(), i, PendingIntent.FLAG_UPDATE_CURRENT);
          mAlarmManager.set(AlarmManager.RTC_WAKEUP, milli, pi);
  }
  </code></pre>
  
  <p>I have noticed that whenever <code>mAlarmManager.set();</code> is executed successfully the <code>LogCat</code> shows  notification like<br>
  <code>"enqueueToast pkg=com.jellboi.android.togglemode callback=android.app ITransientNotification$stub$proxy@43c0c5f8 duration=0"</code>    </p>
  
  <p>but when I set both the alarms simultaneously  the notification is not shown when the <code>mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pi);</code> is executed
  but the notification is shown when <code>mAlarmManager.set(AlarmManager.RTC_WAKEUP, milli, pi);</code> is executed. Also the notification is set for the original time i.e. 2'O clock and not after adding 15mins to it's duration.</p>
  
  <p>Please help, I tried a lot of ways to call this functions at different places like after the 1st alarm is fired but all in vain.</p>