Multiple Alarm fire at same time
<p>i have a problem with triggering the multiple alarm at first time , here is my code </p>

<p>it is launcher activity where i write the following code ::</p>

<p>**onCreate Method :</p>

<pre><code>// Calling Method setNextAlarm two times..with different id and time 

    setNextAlarm(0,60000);
    setNextAlarm(1,120000);
</code></pre>

<p>and the setNextAlarm is here ::</p>

<pre><code>    private void setNextAlarm(int id,long time) {
            AlarmManager mgr = (AlarmManager) TestAct.this
            .getSystemService(Context.ALARM_SERVICE);
            Intent i = new Intent(TestAct.this, OnBootReceiver.class);
            i.putExtra("id", id);

            Log.e("Firing up next alarm in "+id,""+time/(60*1000) +"minutes");

            PendingIntent pi = PendingIntent.getBroadcast(TestAct.this, id, i,PendingIntent.FLAG_ONE_SHOT);
            mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, time, pi);
   }
</code></pre>

<p>when i run this code it calls the onBootReceiver which is our Broadcast receiver class.</p>

<p><strong>So My question is ::</strong> </p>

<p>After defining the different time and id in this method</p>

<pre><code>setNextAlarm(0,60000);
setNextAlarm(1,120000);
</code></pre>

<p><strong>why it fires at same time ? Except the first time it runs fine at fixed interval.</strong></p>

<p>this is my onBootReceiver class's onReceive method</p>

<pre><code>Bundle b = intent.getExtras();  

int id = b.getInt("id");

if(id==1){
    PERIOD=300000;
}else{
    PERIOD=120000;
}

Log.e("OnBootReceiver"," Calling"+id+" in "+PERIOD/60000 + "minutes");

AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
   Intent i=new Intent(context, OnAlarmReceiver.class);
   i.putExtra("id", id);
   PendingIntent pi=PendingIntent.getBroadcast(context, id,i, 0);
   mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                      SystemClock.elapsedRealtime()+60000,
                      PERIOD,
                      pi);
</code></pre>

<p>Thanks.</p>
