Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to create an alarm using Symbian C++

From Wiki
Jump to: navigation, search

This code snippet shows how to set an alarm using Symbian C++. This alarm is different from the clock application's alarm and picks the same tone set for the calendar application's alarm. If vibration alert is enabled for the currently set profile, then a vibrating alert will also be played when the alarm expires.

Article Metadata
Tested with
SDK: S60 3rd Edition
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData, ReadUserData, WriteDeviceData, WriteUserData
Created: judith14 (28 May 2007)
Last edited: hamishwillee (06 Aug 2012)
#include <ASCliSession.h>
#include <ASShdAlarm.h>
#include <ASShdDefs.h>
Link Against : alarmclient.lib
Link Against : alarmshared.lib
RASCliSession iSession;  // client interface to alarm server
TASShdAlarm iAlarm; //Alarm object
TTime ihomeTime;
ihomeTime.HomeTime(); // Get Current Hometime(local time set in mobile)
Tint interval;
// interval – Give seconds after which alarm should expire
TTimeIntervalSeconds intervalSecs(interval);
//Returns the time alarm is scheduled to expire
TTime& iNDT = iAlarm.NextDueTime();
//Set the NextDueTime in which alarm will expire
iNDT = ihomeTime + intervalSecs;
TAlarmMessage& imessage(iAlarm.Message());
imessage.Copy(_L("Alarm")); //Alarm message

The application should have following capabilities for alarm to work. ReadDeviceData, ReadUserData, WriteDeviceData and WriteUserData.

If the application doesn't have any of the above required capabilities, it returns error KErrPermissionDenied(-46).

This page was last modified on 6 August 2012, at 02:13.
37 page views in the last 30 days.