Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-3B441CDC-AB7A-4D8D-A595-57C21E1D426C" xml:lang="en"><title>Foreground
events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The application framework calls <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeAppUiClass.html#%3a%3aCCoeAppUi%3a%3aHandleForegroundEventL%28TBool%29" format="application/java-archive"><parmname>CCoeAppUI::HandleForegroundEventL()</parmname></xref> when the application
is switched to the foreground or background.</p>
<p>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.</p>
<p>An example of such a foreground event implementation is as follows:</p>
<codeblock id="GUID-ECF10193-AB06-4267-A47F-D5EC2C561D9C" xml:space="preserve">// ------------------------------------------------------------------------------
// 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" ) );
}
}
</codeblock>
<p>The <parmname>aForeground</parmname> parameter is true if the application
is switched to the foreground (is visible) and false if the application has
gone to the background</p>
<note>
<p>The above code snippet uses the <i>MyView</i> example application provided
in the <i>S60 Platform: Platform Application Views</i> package available from <xref href="http://www.forum.nokia.com/info/sw.nokia.com/id/9c5f21fd-2162-42da-aaf6-17a59b943475/S60_Platform_Application_Views_v2_0_en.zip.html" scope="external">Forum
Nokia</xref> . </p>
</note>
</conbody></concept>