×
Namespaces

Variants
Actions

Handle Profile Activation

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: sinhashivam (16 May 2007)
Last edited: hamishwillee (23 Jul 2012)
You can get notifocations for profile activations and handle them inside your applications.

Library Needed:

LIBRARY PlatformEnv.lib  //CSettingInfo

In Header File

#include <settinginfo.h>	// CSettingInfo
#include <settinginfoids.h> // CSettingInfo ID's
 
//Implement MSettingInfoObserver interface
 
class MyClass:public MSettingInfoObserver
{
/*
* Notification handler method
*
* param aID is the ID of changed setting
*
* param aNewValue is the new value of the changed setting
* given as text, and to be (possibly)
*converted into an integer when needed
*/

 
void HandleNotificationL( SettingInfo::TSettingID aID,
const TDesC& aNewValue );
 
private:
 
CSettingInfo* iSettings;
}

In the CPP File

CMyClass::ConstructL()
{
// Create a new instance of CSettingInfo. All profile
// non observalbe properties (all except the profile
// index) are read using this instance
 
iSettings = CSettingInfo::NewL(this);
 
// Order notifications when profile is changed
TInt err = iSettings->NotifyChanges(SettingInfo::EActiveProfile);
if(err != KErrNone)
{
// an error occured, show message to user
//iView->ShowMessageL(KErrOrderingProfileChangeNotifies);
 
}
 
}
 
 
//=========================================================================
//
//
//
//
//==========================================================================
 
 
void CMyClass::HandleNotificationL(SettingInfo::TSettingID aID,
const TDesC& aNewValue )
{
TInt err(0);
switch(aID)
{
case SettingInfo::EActiveProfile:
{
// First, parse the NEW active profile index
// out from the value string by using TLex
//TInt profileIdx(iProperties.profileIndex);
//this->iapp->InForeGround();
 
TLex parsed(aNewValue);
TInt value;
 
if ( (err = parsed.Val(value)) == KErrNone )
{
//Parsing successful
 
if(value==0)
//"General" Profile is Activated
if(value==1)
//"Silent" Profile is Activated
if(value==2)
//"meeting" Profile is Activated
if(value==3)
//"Outdoor" Profile is Activated
if(value==4)
//"Pager" Profile is Activated
if(value==5)
//"Offline" Profile is Activated
 
 
}
else
{
// parsing failed.....
 
}
break;
}
 
default:
break;
}
}


Related Links:

This page was last modified on 23 July 2012, at 10:53.
34 page views in the last 30 days.