Activating an Alarm on Given Days

This tutorial explains the steps required to activate an alarm that expires, or goes OFF on one or more days of the week.


The TASShdAlarm class provides functions that enable an alarm to repeat on specified days of the week. This alarm is known as a Daily On Given Days alarm. The alarm can be repeated weekly on a single day or on multiple days. The alarms can also be repeated at the same time on every specified day.

If the user changes the system date or time, the alarm expires once. Unlike a Repeat Once alarm, a Daily On Given Days alarm is not deleted but rescheduled for the next available expiry time.


Follow the steps given below to create a Daily On Given Days alarm that is active on Monday and Wednesday of every week:

  1. Create an alarm with the TASShdAlarm class.

  2. Use theSetAlarmDays() API to specify the required days. EAlarmDayMonday and EAlarmDayWednesday are the parameters to specify that the alarm must repeat on Monday and Wednesday as shown in the code fragment.

    NOTE: [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TASShdAlarmRASCliSession']]]SetAlarmDays() must be specifically used for EAlarmRepeatDefinitionRepeatDailyOnGivenDays repeat definition only.

  3. Use RASCliSession to create a session with the Alarm Server.

  4. Add the alarm to the Alarm Server using the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TASShdAlarmRASCliSession']]]AlarmAdd() API.

The following code fragment illustrates how to activate an alarm on the given days:

#include <ASCliSession.h>    // For RASCliSession.
#include <ASShdAlarm.h>      // For TASShdAlarm.


// Create an alarm that is active on Monday and Wednesday.
TASShdAlarm alarm;
alarm.RepeatDefinition() = EAlarmRepeatDefinitionRepeatDailyOnGivenDays;
alarm.SetAlarmDays( EAlarmDayMonday | EAlarmDayWednesday );

// Connect to Alarm Server.
RASCliSession alarmSession;
User::LeaveIfError( alarmSession.Connect() );
CleanupClosePushL( alarmSession );

// Add the alarm to Alarm Server.
User::LeaveIfError( alarmSession.AlarmAdd( alarm ) );



The alarm is set to repeat every week on Monday and Wednesday.

Related concepts