Code:
MCoeForegroundObserver::HandleLosingForeground()
{
const TUid KNativeCameraAppUID = { 0x101ffa86}; //The UID of the native camera application
TUid id( KNativeCameraAppUID);
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );
if ( task.Exists() ) //If the native camera application is running
{
RWsSession WsSession = CCoeEnv::Static()->WsSession();
TWsEvent event;
TInt ForegroundWinGroup = WsSession.GetFocusWindowGroup();
if (task.WgId()==ForegroundWinGroup) //If the native camera application is on the foreground
{
const TUid KCurrentAppUID = { 0x20004A79 }; //The UID of current runing application
TUid thisid( KCurrentAppUID );
TApaTaskList taskList1( CEikonEnv::Static()->WsSession() );
TApaTask task1 = taskList1.FindApp( thisid );
if ( task1.Exists() )
{
task1.BringToForeground();
}
}
}
}