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. Thanks for all your past and future contributions.

Enabling and disabling all key sounds using CAknKeySoundSystem

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia N93
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Keywords: CAknKeySoundSystem, CAknAppUi, CAknAppUi::KeySounds(), CAknKeySoundSystem::PushContextL(), CAknKeySoundSystem::BringToForeground(), CAknKeySoundSystem::LockContext(), CAknKeySoundSystem::PopContext(), CAknKeySoundSystem::ReleaseContext()
Created: aknyman (09 May 2008)
Last edited: hamishwillee (14 Jun 2013)



This code snippet shows how CAknKeySoundSystem is used to enable/disable all key sounds at once with the predefined key map list R_AVKON_SILENT_SKEY_LIST.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY avkon.lib
LIBRARY eikcore.lib
LIBRARY eiksrv.lib

Header file

 #ifndef __TESTERAPPVIEW_H__
#include <coecntrl.h>
class CAknKeySoundSystem;
class CTesterAppView : public CCoeControl
CAknKeySoundSystem* iSoundSystem;
TBool iSilentKeys;
#endif // __TESTERAPPVIEW_H__

Source file

#include <avkon.rsg>  //R_AVKON_SILENT_SKEY_LIST
#include <aknsoundsystem.h> // CAknKeySoundSystem
#include <aknappui.h>
void CTesterAppView::ConstructL(const TRect& aRect)
iSilentKeys = EFalse;
iSoundSystem = static_cast<CAknAppUi*>(
CEikonEnv::Static()->AppUi() )->KeySounds();
if (!iSoundSystem)
//pointer to KeySound API object is null
iSoundSystem = NULL;
// ---------------------------------------------------------------------------
// Disable all key sounds
// ---------------------------------------------------------------------------
void CTesterAppView::DisableAllKeySoundsL()
if ( iSoundSystem && !iSilentKeys )
//load key sound map from resources and push it to the context stack
iSoundSystem->PushContextL( R_AVKON_SILENT_SKEY_LIST );
//tell server to use this context stack for processing sounds
//lock this context to the foreground, other BringToForeground() calls
//will be ignored until ReleaseContext() is called
iSilentKeys = ETrue;
// ---------------------------------------------------------------------------
// Enable all key sounds
// ---------------------------------------------------------------------------
void CTesterAppView::EnableAllKeySounds()
if ( iSoundSystem && iSilentKeys )
//release the locked context
//pop the pushed context from the context stack
iSilentKeys = EFalse;


The key sounds are enabled/disabled by calling the methods DisableAllKeySoundsL() and EnableAllKeySounds().

See also

Archived:Enabling and disabling defined key sound using CAknKeySoundSystem

Archived:Using customized key sounds with CAknKeySoundSystem

This page was last modified on 14 June 2013, at 04:52.
26 page views in the last 30 days.