I register alarms that I plan to execute at the moment, and there can be many alarms depending on the size of the planned list. But I have two questions that are still unclear to me:
1) How can I request an OS for pending intent registers? I need this for testing. The psudo code for what I want will be something like this:
List<PendingIntent> intentsInOS = context.getAllPendingIntentsOfType(AppConstants.INTENT_ALARM_SCHEDULE));
2) See the pending intention that I create, I provide the action and additional data (schedule identifier).
private Intent getSchedeuleIntent(Integer id) { Intent intent = new Intent(AppConstants.INTENT_ALARM_SCHEDULE); intent.putExtra(AppConstants.INTENT_ALARM_SCHEDULE_EXTRA, id); return intent; }
But we also say that this intention has FLAG_CANCEL_CURRENT. Will it cancel all pending intentions with the same action or will it have both one action and additional data?
PendingIntent pendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, getSchedeuleIntent(schedule.id), PendingIntent.FLAG_CANCEL_CURRENT);
My code
@Override public void run() { List<ScheduledLocation> schedules = dbManager.getScheduledLocations(); if(schedules == null || schedules.isEmpty()){ return; } AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Thomas vervik
source share