Setting up of multiple alarms in android
<p>i am having this code for setting multiple alarms for creating a reminder application .The code works fine when a single alarm is put.  However when i set mutiple alarms I am getting only the first reminder and that too invoked when the alarm time of the last reminder is reached.</p>

<pre><code>          import java.util.Calendar;

          import android.app.AlarmManager;
          import android.app.PendingIntent;
          import android.content.Context;
          import android.content.Intent;
</code></pre>

<p>public class ReminderManager {</p>

<pre><code>private Context mContext; 
private AlarmManager mAlarmManager;

public ReminderManager(Context context) {
    mContext = context; 
    mAlarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
}

public void setReminder(Long taskId, Calendar when) {

    Intent i = new Intent(mContext, OnAlarmReceiver.class);
    i.putExtra(RemindersDbAdapter.KEY_ROWID, (long)taskId); 

    PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); 

    mAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), pi);
}
</code></pre>

<p>}</p>

<p>On alarm reciever i have </p>

<p>public class OnAlarmReceiver extends BroadcastReceiver {</p>

<pre><code>private static final String TAG = ComponentInfo.class.getCanonicalName(); 


@Override   
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "Received wake up from alarm manager.");

    long rowid = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID);

    WakeReminderIntentService.acquireStaticLock(context);

    Intent i = new Intent(context, ReminderService.class); 
    i.putExtra(RemindersDbAdapter.KEY_ROWID, rowid);  
    context.startService(i);

}
</code></pre>

<p>}</p>
