Beispiel #1
0
        public static void ScheduleAlarms(IAlarmListener alarmListener, Context context, bool force)
        {
            ISharedPreferences preferences = context.GetSharedPreferences(NAME, 0);
            long lastAlarm = preferences.GetLong(LAST_ALARM, 0);

            if (lastAlarm == 0 || force ||
                (DateTime.Now.Millisecond > lastAlarm &&
                 DateTime.Now.Millisecond - lastAlarm > alarmListener.GetMaxAge()))
            {
                AlarmManager  manager       = (AlarmManager)context.GetSystemService(Context.AlarmService);
                Intent        intent        = new Intent(context, typeof(AlarmReceiver));
                PendingIntent pendingIntent = PendingIntent.GetBroadcast(context, 0, intent, 0);
                alarmListener.ScheduleAlarms(manager, pendingIntent, context);
            }
        }