Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

通过UID判断某个程序是否在前台运行

From Wiki
Jump to: navigation, search
Article Metadata

文章
User:Davey 2 在 20 Dec 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

适用版本:

S60 2nd Edition, S60 3rd Edition


具体方案:


通过以下代码可以判断一个UID为KUidMyAppUid的程序是否运行在前台,若是返回ETrue,若否则返回EFalse。

TBool MyApplication::IsTaskInForegroundL()
{
RWsSession& wsSession = CEikonEnv::Static()->WsSession();
CArrayFixFlat<TInt>* wgIds = new (ELeave) CArrayFixFlat<TInt>(2);
CleanupStack::PushL(wgIds);
wsSession.WindowGroupList(0, wgIds);
TInt WgId = (*wgIds)[0];
CleanupStack::PopAndDestroy(); // wgIds

CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(wsSession, WgId);
TUid uid = wgn->AppUid();
CleanupStack::PopAndDestroy();

if (uid == KUidMyAppUid) // Put UID of your application.
return ETrue;
else
return EFalse;
}

This page was last modified on 15 December 2011, at 06:38.
138 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×