开发者

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

开发者 https://www.devze.com 2023-04-06 17:40 出处:网络
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

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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消