Intent intent = new Intent(a, AlarmReceiver.class);
intent.putExtra("row_id", rowId);
final int alarmId = (int) System.currentTimeMillis();
PendingIntent sender = PendingIntent.getBroadcast(a, alarmId, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) a.getSystemService(a.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender);
Notice the "alarmId" above. By setting different private request codes as an argument for the getBroadcast function, you can schedule multiple alarms. If you use the same id, the previous alarms scheduled will be cancelled.
useful information! thanks!!
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethanks it solved my issue
ReplyDeleteThanks so much!! thats what I was looking for for. keep it up :)
ReplyDeleteHi my code for multiple alarm is not working
ReplyDeletecan u plzz help me out?
Thanx in advance
Intent intentAlarm = new Intent(MainActivity.this,AlarmReceiver.class);
final int _id = (int) System.currentTimeMillis();
Log.d("id",_id+"");
PendingIntent intent = PendingIntent.getBroadcast(this, _id, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
long r4=r3+new GregorianCalendar().getTimeInMillis();
AlarmManager alarmManager=(AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,r4, intent);
:( code not working for me.
DeleteIntent intent = new Intent(MainTabBottomActivity.this, MyAlarmService.class);
// intent.putExtra("row_id", 1);
final int alarmId = (int) System.currentTimeMillis();
PendingIntent sender = PendingIntent.getBroadcast(MainTabBottomActivity.this, alarmId, intent,PendingIntent.FLAG_UPDATE_CURRENT);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
AlarmManager am = (AlarmManager) MainTabBottomActivity.this.getSystemService(MainTabBottomActivity.this.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
its helpful, i can solve my issue, thanks :)
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHello, I have created 5 users at 7:00AM then 4 users is firing on 7:00AM but one user is not hitting or created 7 user at 7:00am then 6 users is firing on 7:00AM but every time missing one user. Can you solve my issue? My email address sameer.digisoft@gmail.com
ReplyDeletei have one doubt
ReplyDeletethanks
ReplyDeleteI like how in 2018, this comment saved my sleepless nights. Thanks sir
ReplyDelete