internal static int?SaveAlarm(AlarmRecord alarmRecord) { Native.AppControl appControl = new Native.AppControl() { ApplicationId = Native.Application.Current.ApplicationInfo.ApplicationId }; appControl.ExtraData.Add("AlarmRecord.DateCreated", alarmRecord.DateCreated.ToString()); Native.AlarmWeekFlag nativeFlag = Convert(alarmRecord.WeekFlag); Native.Alarm nativeAlarm = Native.AlarmManager.CreateAlarm(alarmRecord.ScheduledDateTime, nativeFlag, appControl); return(nativeAlarm.AlarmId); }
/// <summary> /// Creates a system alarm of AlarmRecord /// </summary> /// <param name="binableAlarmRecord">AlarmRecord object to create a system alarm based on</param> /// <seealso cref="AlarmRecord"> /// <returns> Returns native alarm object </returns> public static int CreateAlarm(AlarmRecord record) { Native.AppControl appControl = new Native.AppControl() { ApplicationId = Native.Application.Current.ApplicationInfo.ApplicationId }; appControl.ExtraData.Add("AlarmRecord.UniqueIdentifier", record.GetUniqueIdentifier()); //temporary set AllDays , After implement select day of week. additional implementation should be add. Native.Alarm nativeAlarm = Native.AlarmManager.CreateAlarm(record.ScheduledDateTime, Native.AlarmWeekFlag.AllDays, appControl); Console.WriteLine("@@ [Alarm.CreateAlarm] UID : " + record.GetUniqueIdentifier() + ", ScheduledDateTime : " + record.ScheduledDateTime + " NativeAlarmID : " + nativeAlarm.AlarmId); return(nativeAlarm.AlarmId); }
/// <summary> /// Creates a system alarm of AlarmRecord /// </summary> /// <param name="binableAlarmRecord">AlarmRecord object to create a system alarm based on</param> /// <seealso cref="AlarmRecord"> /// <returns> Returns native alarm object </returns> public int CreateAlarm(AlarmRecord record) { Native.AppControl appControl = new Native.AppControl() { ApplicationId = Native.Application.Current.ApplicationInfo.ApplicationId }; appControl.ExtraData.Add("AlarmRecord.UniqueIdentifier", record.GetUniqueIdentifier()); appControl.ExtraData.Add("RingType", RingType.RING_TYPE_ALARM.ToString()); Native.AlarmWeekFlag nativeFlag = Convert(record.WeekFlag); Native.Alarm nativeAlarm = Native.AlarmManager.CreateAlarm(record.ScheduledDateTime, nativeFlag, appControl); #if ALARM_DEBUG System.Diagnostics.Debug.WriteLine("@@ [Alarm.CreateAlarm] UID : " + record.GetUniqueIdentifier() + ", ScheduledDateTime : " + record.ScheduledDateTime + " nativeFlag : " + nativeFlag); System.Diagnostics.Debug.WriteLine(" --> Done Native UID : " + nativeAlarm.AlarmId + ", ScheduledDate : " + nativeAlarm.ScheduledDate + " nativeFlag : " + nativeAlarm.WeekFlag); #endif return(nativeAlarm.AlarmId); }
/// <summary> /// Gets system alarm ID from alarm object /// </summary> /// <param name="alarm">AlarmRecord object to get system alarm ID from</param> /// <seealso cref="AlarmRecord"> /// <returns> Returns system alarm ID </returns> public int GetAlarmID(object alarm) { Native.Alarm nativeAlarm = alarm as Native.Alarm; return(nativeAlarm.AlarmId); }