public override void OnReceive(Context context, Intent intent) { bool bootCompleted; string action = intent.Action; //TODO Switch to UserManagerCompat, BuildCompat Log.Info(TAG, $"Received action {action}, user unlocked: "); //{UserManagerCompat.IsUserUnlocked (context))}"); if (Build.VERSION.SdkInt > BuildVersionCodes.M) { bootCompleted = Intent.ActionLockedBootCompleted == action; } else { bootCompleted = Intent.ActionBootCompleted == action; } if (!bootCompleted) { return; } /* TODO: Fill alarms*/ var util = new AlarmUtil(context); var alarmStorage = new AlarmStorage(context); foreach (Alarm alarm in alarmStorage.GetAlarms()) { util.ScheduleAlarm(alarm); } }
void SetupRequiredFilesAndStart() { InitialSetupHelper initialSetupHelper = new InitialSetupHelper("translations.db3"); if (!initialSetupHelper.IsSetup(LATEST_DICT_HASH)) { initialSetupHelper.CopyDBFromAssets(); } // Cancel and set all alarms var context = ApplicationContext; var util = new AlarmUtil(context); var alarmStorage = new AlarmStorage(context); foreach (Alarm alarm in alarmStorage.GetAlarms()) { util.CancelAlarm(alarm); util.ScheduleAlarm(alarm); } StartActivity(new Intent(Application.Context, typeof(MainActivity))); }
public void TestMethod1() { AlarmUtil.REPEATINTERVAL interval = new AlarmUtil.REPEATINTERVAL(); interval.Daily = false; interval.Monthly = true; interval.DayOfMonth = 12; AlarmUtil.ALARMINFO info = new AlarmUtil.ALARMINFO(); info.AlarmContents = "无备注"; info.AlarmDate = DateTime.Now; info.AlarmName = "测试"; info.CreateDate = DateTime.Now; info.RepeatInterval = interval; string xmlStr = AlarmUtil.GetRepeatIntervalString(info.RepeatInterval); //Debug.WriteLine(xmlStr); var x = AlarmUtil.GetRepeatInfo(xmlStr); Assert.AreEqual(12, x.DayOfMonth); Assert.AreEqual(true, x.Monthly); Assert.AreEqual(false, interval.Once); }