Handling EEikCmdExit

If your Symbian GUI-based application should close, for example, in out of memory situations, you must handle the EEikCmdExit command ID in your override of CEikAppUi::HandleCommandL(). The UI architecture of your application determines where you override CEikAppUi::HandleCommandL(). A typical implementation is as follows:

void CMyCommandHandlingAppUi::HandleCommandL(TInt aCommand)
    {
    	
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;
       
        default:
            break;
        }
    }

where CEikAppUi::Exit() closes the application. CEikAppUi also provides SaveAnyChangesL() and SaveL() methods in case you need to save the application document.

Note: In Symbian view architecture applications, the EEikCmdExit command must be only handled once: either in the UI controller or in a view. Since the exit command is an application wide command, it is recommended that it be handled in the UI controller implementation.

CEikAppUi::Exit() exits the application. If the application is embedded, control returns to the parent, which should also exit. The application framework sends an EEikCmdExit command ID to each application in this chain to support this behavior.

Note: CEikAppUi::Exit() is guaranteed not to return. This means that you should not trap this method. Among other things, do not call another method when you handle the command ID that triggers an exit.