In my AlarmManagerUtils.java page I am creating multiple, single alarms using this method:
public static void createSingleAlarm(Context thisContext, int intDiaryEntryID, long lngAlarmTime){
AlarmManager am = (AlarmManager)thisContext.getSystemService(Context.ALARM_SERVICE);
Intent thisIntent = new Intent(thisContext, AlarmReceiver.class);
thisIntent.setAction("StartSingleAlarm");
thisIntent.putExtra("DiaryEntryID", intDiaryEntryID);
PendingIntent thisPendingIntent = PendingIntent.getBroadcast(thisContext, intDiaryEntryID, thisIntent, 0);
am.set(AlarmManager.RTC_WAKEUP, lngAlarmTime, thisPendingIntent);
}
So I have a bunch of those for different days and times. What I want to do is allow the user to "toggle" alarms off and on from the preferences page. Is there a way to do this? I want to do something like this:
public static void turnOffAllAlarms(Context thisContext){
AlarmManager am = (AlarmManager)thisContext.getSystemService(Context.ALARM_SERVICE);
am.disable(thisContext);
}
and this:
public static void turnOnAllAlarms(Context thisContext){
AlarmManager am = (AlarmManager)thisContext.getSystemService(Context.ALARM_SERVICE);
am.enable(thisContext);
}