Namespaces

Variants
Actions

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 over the next few weeks. Thanks for all your past and future contributions.

Detecting system environment changes on Symbian

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on Nokia 6210 Navigator
Compatibility
Platform(s): S60 3rd Edition, 3rd Edition FP1, 3rd Edition FP2, 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Article
Keywords: CEnvironmentChangeNotifier
Created: User:Kbwiki (30 Oct 2009)
Last edited: hamishwillee (01 Aug 2012)

Overview

This article provides a way to detect changes in the system environment, such as system time change, thread death, or system locale change.

Description

The CEnvironmentChangeNotifier class can be used for this purpose. This is an active object whose constructor takes a reference to a callback function (TCallBack) for handling environment change events.

Solution

Required headers and libraries

 #include <bacntf.h> // Link against bafl.lib

 // NotifyChange is a static member function declared as follows:
// static TInt NotifyChange( TAny* aObject );
 
TCallBack envChangeCallback( NotifyChange, this );
iEnvNotifier = CEnvironmentChangeNotifier::NewL( CActive::EPriorityHigh, envChangeCallback );
 
// Issues a request for change events. When a change events occurs, the
// callback function is called. Note that after the first call to this
// function, the callback function is called immediately.
iEnvNotifier->Start();

Interpreting changes through TChanges enum

 TInt CMyEnvironMentChangeNotifier::NotifyChange( TAny* aObject )
{
CMyEnvironMentChangeNotifier* thisPtr = static_cast<CMyEnvironMentChangeNotifier*>( aObject );
 
// Retrieve the changes in a bit field
const TInt changes( thisPtr->iEnvNotifier->Change() );
 
if( changes & EChangesLocale )
{
// System locale changed
}
if( changes & EChangesMidnightCrossover )
{
// Midnight crossover
}
if( changes & EChangesThreadDeath )
{
// Thread death
}
if( changes & EChangesPowerStatus )
{
// Power status changed
}
if( changes & EChangesSystemTime )
{
// System time changed
}
if( changes & EChangesFreeMemory )
{
// Free memory changed
}
if( changes & EChangesOutOfMemory )
{
// Out of memory
}
}
This page was last modified on 1 August 2012, at 04:39.
47 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×