示例#1
0
        protected override void OnPause()
        {
            base.OnPause();

            ISharedPreferencesEditor editor = data.Edit();
            ICollection <string>     alarms = new List <string> ();

            foreach (Alarm a in alarmService.Alarms)
            {
                alarms.Add(AlarmFactory.AlarmToString(a));
            }
            editor.PutStringSet("alarms", alarms);
            editor.Commit();
        }
示例#2
0
 public override void OnReceive(Context context, Intent intent)
 {
     try {
         data = context.GetSharedPreferences("project_alarm", FileCreationMode.Private);
         if (data != null)
         {
             ICollection <string> alarmStrings = data.GetStringSet("alarms", null);
             alarmService = new AlarmService();
             if (alarmStrings != null)
             {
                 foreach (string a in alarmStrings)
                 {
                     alarmService.Alarms.Add(AlarmFactory.StringToAlarm(a));
                 }
                 alarmService.Alarms.Sort();
                 AlarmMngr.StartAlarm(alarmService.GetNextEnabledAlarm(), context);
             }
         }
     } catch (Exception ex) {
         Console.WriteLine(ex.Message);
     }
 }
示例#3
0
 protected override void OnResume()
 {
     base.OnResume();
     if (!gotActivityResult)
     {
         ICollection <string> alarmStrings = data.GetStringSet("alarms", null);
         alarmService.Alarms.Clear();
         if (alarmStrings != null)
         {
             foreach (string a in alarmStrings)
             {
                 alarmService.Alarms.Add(AlarmFactory.StringToAlarm(a));
             }
             alarmService.Alarms.Sort();
             alarmsListViewAdapter.NotifyDataSetChanged();
             UpdateAlarmManager();
         }
     }
     else
     {
         gotActivityResult = false;
     }
 }