×
Namespaces

Variants
Actions
(Redirected from How to create alarm)

How to create an alarm using Symbian C++

From Nokia Developer 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
Article
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
iSession.Connect();
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
 
iSession.AlarmAdd(iAlarm);
iSession.Close();

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 05:13.
82 page views in the last 30 days.
×