alarms

Multiple calls to AlarmManager.setRepeating deliver the same Intent/PendingIntent extra values, but I supplied different ones

痞子三分冷 提交于 2019-11-27 05:43:05
问题 Solved while writing this question, but posting in case it helps anyone: I'm setting multiple alarms like this, with different values of id : 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, 0, i, 0); alarms.setRepeating(AlarmManager.RTC_WAKEUP, nextMillis, 300000, p); // 5

Android AlarmManager after reboot

允我心安 提交于 2019-11-26 18:37:49
I have a set of alarms that I need to keep after reboot. I've tried using on an boot receiver but they won't start again. I'm not sure if I understand the boot receiver and how to then restart all the alarms. I already have one receiver for my notifications, but don't know whether I can use the same receiver or if I need a new one? Could anyone point me to any good tutorials or help me out? Cheers Code : DatabaseHandler db = new DatabaseHandler(this); List<UAlarm> alarms = db.getAllAlarms(); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); for (UAlarm ua : alarms) {