title: how to set multiple, repeating pending intent using android alarm manager?
body: <p>I'm making an app in which i need to turn my phone into the vibration mode at the scheduled time.
  The problem is that only the second pending intent is executed.
  How can I start multiple pending intents?</p>
  
  <p>My code:</p>
  
  <pre><code>import java.util.Calendar;
  import android.app.Activity;
  import android.app.AlarmManager;
  import android.app.PendingIntent;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.widget.CheckBox;
  import android.widget.Toast;
  
  public class GetSlots extends Activity {
  
      private Calendar mCalendar;  
      private Calendar nCalendar;
      private CheckBox a1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_slots);
          addenable();
  
          a1 = (CheckBox)findViewById(R.id.checkBox2);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }   
  
      public void addenable() {
      }
  
      public void getdata(View V) {
  
          mCalendar= Calendar.getInstance();
          mCalendar.set(Calendar.HOUR_OF_DAY, 16 );
          mCalendar.set(Calendar.MINUTE, 27);
          mCalendar.set(Calendar.SECOND, 0);
  
          nCalendar= Calendar.getInstance();
          nCalendar.set(Calendar.HOUR_OF_DAY, 16 );
          nCalendar.set(Calendar.MINUTE, 29);
          nCalendar.set(Calendar.SECOND, 0);
  
          Intent intentAlarm = new Intent();
          intentAlarm.setClass(this, AlarmReciever.class);
  
          PendingIntent i = PendingIntent.getBroadcast(this, 0, intentAlarm,
                  PendingIntent.FLAG_UPDATE_CURRENT);
  
          PendingIntent j = PendingIntent.getBroadcast(this, 0, intentAlarm,
                  PendingIntent.FLAG_UPDATE_CURRENT);
  
          // create the object
          AlarmManager mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  
          if(a1.isChecked()) {
              mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, mCalendar.getTimeInMillis(),500*1000, i);
              Toast.makeText(this, "Alarm Scheduled", Toast.LENGTH_LONG).show();
  
              mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, nCalendar.getTimeInMillis(), 1000*1000, j);
              Toast.makeText(this, "Alarm Scheduled", Toast.LENGTH_LONG).show();
          }
  
          if(!a1.isChecked()) {
              PendingIntent.getBroadcast(this, 0, intentAlarm,
                      PendingIntent.FLAG_UPDATE_CURRENT).cancel();
          }
      }
  }
  </code></pre>