title: Scheduling multiple alarms
body: <p>I'm trying to trigger 3 alarms at different times using alarm manager. Here's my code (Note that alarm1, alarm2, alarm3 are three calender objects set earlier in my code):</p>
  
  <pre><code>AlarmNum=1;
  new Runnable() {
  
          @Override
          public void run() {
              // TODO Auto-generated method stub
  
              // TODO Auto-generated method stub
              Intent myIntent = new Intent(MainActivity.this,
                      MyAlarmService.class);
              pendingIntent = PendingIntent.getService(MainActivity.this, 0,
                      myIntent, 0);
  
              if (AlarmNum == 1)
                  alarmManager.set(AlarmManager.RTC_WAKEUP,
                          alarm1.getTimeInMillis(), pendingIntent);
              else if (AlarmNum == 2)
                  alarmManager.set(AlarmManager.RTC_WAKEUP,
                          alarm2.getTimeInMillis(), pendingIntent);
              else
                  alarmManager.set(AlarmManager.RTC_WAKEUP,
                          alarm3.getTimeInMillis(), pendingIntent);
  
              Toast.makeText(MainActivity.this, "Start Alarm",
                      Toast.LENGTH_LONG).show();
          }
      };
  </code></pre>
  
  <p>In the above code I start an intent which provokes MyAlarmService class given below:</p>
  
  <pre><code>public class MyAlarmService extends Service {
  MainActivity instance;
  MediaPlayer mp;
  
  @Override
  public void onCreate() {
      // TODO Auto-generated method stub
      Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG)
              .show();
      mp = MediaPlayer.create(this, R.raw.alarmtone);
      instance = new MainActivity();
  }
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      Toast.makeText(this, "MyAlarmService.onBind()", Toast.LENGTH_LONG)
              .show();
      return null;
  }
  
  @Override
  public void onDestroy() {
      // TODO Auto-generated method stub
      super.onDestroy();
      Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG)
              .show();
  }
  
  @Override
  public void onStart(Intent intent, int startId) {
      // TODO Auto-generated method stub
      super.onStart(intent, startId);
      Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG)
              .show();
      mp.start();
      instance.setAlarmNum(instance.getAlarmNum() + 1);
  }
  
  @Override
  public boolean onUnbind(Intent intent) {
      // TODO Auto-generated method stub
      mp.release();
      mp.reset();
      Toast.makeText(this, "MyAlarmService.onUnbind()", Toast.LENGTH_LONG)
              .show();
      return super.onUnbind(intent);
  }
  </code></pre>
  
  <p>}
  I assume there is a problem here because the toasts never show up and neither does the alarm.</p>