As we know, S60 has a funtion called IsForeground() in CAknAppUiBase Class. But there's no equivalent in UIQ, so how to do this in UIQ? Here's a possible solution.
TBool CForegroundAppUi::AppIsForground()
{
TApaTaskList list( iEikonEnv->WsSession() );
TApaTask app = list.FindByPos( 0 );
TBool response;
CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), app.WgId() );
if ( wgName->AppUid().iUid == 0xe4414862 ) // 0xe4414862 is the UID of the application
response = ETrue;
else
response = EFalse;
CleanupStack::PopAndDestroy( wgName );
return response;
}
You can also use the thread id to do the same thing because TApaTask class has a function called ThreadId(). Give a try.