Foreground events

The application framework calls CCoeAppUI::HandleForegroundEventL() when the application is switched to the foreground or background.

While the default implementation of this method is empty, it can be, for example, used to display messages or pause a game when a focus change event occurs.

An example of such a foreground event implementation is as follows:

// ------------------------------------------------------------------------------
// CMyViewAppUi::HandleForegroundEventL(TBool aForeground)
// This function is called by the  framework when the screen loses or gains focus. 
// i.e. when it goes to the background or to the foreground. Incoming call 
// softnote is an example.
// This event applies to the entire application, all views.
// ------------------------------------------------------------------------------
//
void CMyViewAppUi::HandleForegroundEventL(TBool aForeground)
    {
    if( aForeground == TRUE )
        {
        iEikonEnv->InfoMsg( _L( "Foreground true" ) );
        }
    else
        {
        iEikonEnv->InfoMsg( _L( "Foreground false" ) );
        }
    }

The aForeground parameter is true if the application is switched to the foreground (is visible) and false if the application has gone to the background.

Note: The above code snippet uses the MyView example application provided in the Platform Application Views package available from Nokia Developer .