[DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_with_recurrence_week_flag")]
internal static extern int CreateAlarmRecurWeek(SafeAppControlHandle appControl, ref DateTime date, int week, out int alarmId);
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_with_recurrence_seconds")]
+ internal static extern int CreateAlarmRecurForService(SafeAppControlHandle appControl, ref DateTime date, int period, out int alarmId);
+
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_once_after_delay")]
+ internal static extern int CreateAlarmOnceAfterDelayForService(SafeAppControlHandle appControl, int delay, out int alarmId);
+
+ [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_service_once_at_date")]
+ internal static extern int CreateAlarmOnceAtDateForService(SafeAppControlHandle appControl, ref DateTime date, out int alarmId);
+
[DllImport(Libraries.Alarm, EntryPoint = "alarm_get_scheduled_recurrence_week_flag")]
internal static extern int GetAlarmWeekFlag(int alarmId, out int weekFlag);
{
using System;
using System.Collections.Generic;
+ using System.ComponentModel;
using System.Runtime.InteropServices;
using Tizen.Applications.Notifications;
return CreateAlarm(delay, (int)standardPeriod, notification);
}
+ /// <summary>
+ /// Sets an alarm to be triggered after a specific time.
+ /// The alarm will go off delay seconds later.
+ /// </summary>
+ /// <param name="delay"> The amount of time before the execution (in seconds). </param>
+ /// <param name="appControl"> The destination AppControl to perform a specific task when the alarm is triggered. </param>
+ /// <returns> An alarm instance is created with the set param values.</returns>
+ /// <remarks>
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <since_tizen> 12 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(int delay, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAfterDelayForService(appControl.SafeAppControlHandle, delay, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
+ /// <summary>
+ /// Sets an alarm to be triggered at a specific time.
+ /// The date describes the time of the first occurrence.
+ /// </summary>
+ /// <param name="value"> The first active alarm time. </param>
+ /// <param name="appControl"> The destination AppControl to perform specific work when the alarm is triggered. </param>
+ /// <returns> An alarm instance is created with the set param values.</returns>
+ /// <remarks>
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <since_tizen> 12 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(DateTime value, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmOnceAtDateForService(appControl.SafeAppControlHandle, ref time, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
+ /// <summary>
+ /// Sets an alarm to be triggered at a specific time.
+ /// The alarm will first go off at a specific time and then will go off every certain amount of time defined using period seconds.
+ /// </summary>
+ /// <param name="value"> The first active alarm time. </param>
+ /// <param name="period"> The amount of time between subsequent alarms (in seconds).</param>
+ /// <param name="appControl"> The destination AppControl is used to perform a specific task when the alarm is triggered. </param>
+ /// <returns> An alarm instance is created with the set param values.</returns>
+ /// <remarks>
+ /// This operation only allows service application which has Background Category to set an exact alarm.
+ /// This API can have a significant impact on power usage when the device is in idle state, so apps that use it may greatly increase battery consumption.
+ /// Therefore, caution should be taken when using this API.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <since_tizen> 12 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Alarm CreateAlarmForServiceApp(DateTime value, int period, AppControl appControl)
+ {
+ if (appControl == null)
+ {
+ throw AlarmErrorFactory.GetException(AlarmError.InvalidParameter, "AppControl should be not null");
+ }
+
+ Alarm alarm = null;
+ int alarmId;
+ Interop.Alarm.DateTime time = ConvertDateTimeToStruct(value);
+ AlarmError ret = (AlarmError)Interop.Alarm.CreateAlarmRecurForService(appControl.SafeAppControlHandle, ref time, period, out alarmId);
+ alarm = new Alarm(alarmId);
+ if (ret != AlarmError.None)
+ {
+ throw AlarmErrorFactory.GetException(ret, "Failed to create Alarm");
+ }
+
+ return alarm;
+ }
+
/// <summary>
/// Cancels all scheduled alarms that are registered by the application that calls this API.
/// </summary>