Pattabi Raman
Pattabi Raman

Reputation: 5854

How to set more than one alarm for calendar events in android?

I have already worked on calendar events and for each event the alarm should ring with notification. The problem i face is, If i set more than one event, the last set event is alone notifying the user with alarm. But all the other events doesn't ring alarm. Any Help is appreciated and thanks in advance...

Upvotes: 1

Views: 352

Answers (1)

Pratik
Pratik

Reputation: 30855

If you create the alarm with the Single Intent instant you need to pass the different Request code into the getService() method.

Or if you elsewhere you can create multiple instant of the intent and with different request code you can set it

here snippet of code updated

AlarmManager alarms = (AlarmManager)context.getSystemService(
        Context.ALARM_SERVICE);
Intent i = new Intent(MyReceiver.ACTION_ALARM);  // "com.example.ALARM"
i.putExtra(MyReceiver.EXTRA_ID, id);  // "com.example.ID", 2
PendingIntent p = PendingIntent.getBroadcast(context, requestcode, i, 0);

here the second parameter of getService was request code you need to set the different request for multiple alarm.

Upvotes: 1

Related Questions