0

I am having a reminder application in which i have an alarm manager like this

public class ReminderManager {

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) {
     System.out.println("**********************************remindedrmanager************************" );

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

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

    mAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), pi);
}
}

I am getting only one alram even if I set multiple alarm. Is the problem due to some mistake in the above code or is it because of some other mistake.

Janusz
  • 187,060
  • 113
  • 301
  • 369
Ashish Augustine
  • 1,784
  • 4
  • 20
  • 50

1 Answers1

1

You have change argument no 2 in line where you declared pending Intent as per below code. Instead specify (int)System.currentTimeMillis() in place of 0

And also android set multiple alarms simultaneosuly

PendingIntent pi = PendingIntent.getBroadcast(mContext,(int)System.currentTimeMillis(), i, PendingIntent.FLAG_UPDATE_CURRENT);
Community
  • 1
  • 1
Maneesh
  • 6,098
  • 5
  • 36
  • 55