How to create alarm


Reviewer Approved    
The following code snippet explains how to set an alarm in S60. This alarm is different from from the clock application's alarm and picks the same tone set for the calendar application's alarm. If vibration alert is on for the currently set profile, then vibrating alert will also be played when the alarm expires.
SDK Used : S60 3rd edition
#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();


Description
S60 devices that are switched off can switch on automatically to react to alarm events.
In the alarm startup mode, the user will see and hear the alarm and can choose whether the phone will be switched on.
The alarm server (RASCliSession) can be used to set an alarm to wake up the phone in the alarm startup mode.
Solution
Alarms can be set programmatically to turn on the device (in alarm startup mode) at a specified time. Note however, that there are no APIs available to initiate a normal power-up cycle directly - when using alarms, user interaction is required to switch on the device in alarm startup mode.
A specific flag must be set for the alarm (TASShdAlarm) to indicate that it is a wakeup alarm and should wake the device up even when powered off.
const TInt KWakeupAlarmFlagIndex = 0;
 
 TASShdAlarm alarm;
 alarm.ClientFlags().Set( KWakeupAlarmFlagIndex );

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值