/** * This will delete and unregister all instances associated with alarmId, without affect the alarm * itself. This should be used whenever modifying or deleting an alarm. * * @param context application context * @param alarmId to find instances to delete. */ public static void deleteAllInstances(Context context, long alarmId) { ContentResolver cr = context.getContentResolver(); List<AlarmInstance> instances = AlarmInstance.getInstancesByAlarmId(cr, alarmId); for (AlarmInstance instance : instances) { unregisterInstance(context, instance); AlarmInstance.deleteInstance(context.getContentResolver(), instance.mId); } updateNextAlarm(context); }
/** * This will set the alarm instance to the SILENT_STATE and update the application notifications * and schedule any state changes that need to occur in the future. * * @param context application context * @param instance to set state to */ public static void setDismissState(Context context, AlarmInstance instance) { LogUtils.v("Setting dismissed state to instance " + instance.mId); // Remove all other timers and notifications associated to it unregisterInstance(context, instance); // Check parent if it needs to reschedule, disable or delete itself if (instance.mAlarmId != null) { updateParentAlarm(context, instance); } // Delete instance as it is not needed anymore AlarmInstance.deleteInstance(context.getContentResolver(), instance.mId); // Instance is not valid anymore, so find next alarm that will fire and notify system updateNextAlarm(context); }