Namespaces
Variants
Actions

Getting Notification of System Time Change

Jump to: navigation, search
Article Metadata

Code Example
Article
Created: vasant21 (07 May 2007)
Last edited: hamishwillee (23 Jul 2012)

For getting the Notification of System Time Change, we can use RTimers.

The At timers terminates with KErrAbort when the system time changes, the timer can be used to monitor changes in system time.


Implement a simple Active Object and Use RTimer to get notification of System Change.

To get complete idea about Active Object with example refer Active Objects section on wiki.

TTime CurrentTime;
CurrentTime.HomeTime();
 
// Issue an Asynchronous Request //
iTimeWaster.At(iStatus, CurrentTime + TTimeIntervalYears(2));
 
// set it to active once request is issued //
SetActive();

Now in the RunL() of your Active Object, you can catch KErrAbort when the System Time is changed, as timer will terminate with KErrAbort when the system time is changed.

void CSomeActiveObject::RunL()
{
// This is the case when system time is changed and
// hence will cause the timer to abort with KErrAbort.
 
if(iStatus.Int() == KErrAbort)
{
// Do Something ...
}
}


For testing the System Time Change Notification, you can run your program in the background and change the system time from Tools >> Clock >> Settings >>Time, your RunL() method will be called with iStatus = KErrAbort.

See the ready to run example.

"HelloWorldBasic(TimeChanged).zip" File:Helloworldbasic(TimeChanged).zip

This page was last modified on 23 July 2012, at 10:40.
103 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved