Keeping a Symbian application running in the background on exit
Article Metadata
Tested with
Devices(s): Nokia N95
Nokia N96
Nokia E72
Nokia N96
Nokia E72
Compatibility
Platform(s): S60 5th Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 3rd Edition, FP1
S60 3rd Edition, FP2
Article
Keywords: CApaWindowGroupName, HideApplicationFromFSW
Created: User:Kbwiki
(23 Mar 2013)
Last edited: hamishwillee
(24 Aug 2012)
Description
There are instances where some time-consuming operations need to be done during application exit. To avoid unneccessary delays and improve usability, an application can be switched to the background and hidden from the task list/fast-swap window once user interaction is no longer required.
Note: For a better user experience: If you 'Set' the 'Exit' button in your project to 'Hide' your application rather than shutting it down; You are advised to show a note informing the user that your application is running in the background and not entirely closed.
Solution
The application can be hidden and made to run in the background using the below code in the implementation of the AppUI class.
#include <apgwgnam.h> // link against apgrfx.lib
#include <w32std.h> // link against ws32.lib
CMyAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
{
CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(
iEikonEnv->WsSession(),
iEikonEnv->RootWin().Identifier() );
wgName->SetHidden( ETrue );
wgName->SetWindowGroupName( iEikonEnv->RootWin() );
// Hide the application from fast-swap window
// CAknAppUi::HideApplicationFromFSW() is available
// from S60 3rd Ed, FP1 onwards
HideApplicationFromFSW( ETrue );
// Send this application to background
iEikonEnv->RootWin().SetOrdinalPosition( -1 );
CleanupStack::PopAndDestroy( wgName );
// Proceed to do cleanup and call Exit() when done.
break;
}
...


(no comments yet)