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.

Series60 2nd应用程序间的通信

From Wiki
Jump to: navigation, search
Article Metadata

beover1984 在 27 Jul 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

通过Symbian OS的Application Architecture Services可以进行应用程序间的通信,主要用到的类包括:TApaTaskList和TApaTask。


TApaTask:表示设备中某个运行的任务,通过与程序关联的窗口组(window group)标识。

发送消息端:使用TApaTaskList找到等待接收消息的任务,TApaTaskList::FindApp()提供了两个重载版本,可以使用程序的标题,也可以使用程序的UID进行查找。获得接收消息的任务后就可以通过TApaTask:: SendMessage()发送消息了,它有两个参数,第一个参数用于标识消息,第二个参数是一个描述符的引用,可以用来提供不同消息时附加的信息。

      TUid uid( TUid::Uid( 0x0116C9D3 ) );
TApaTaskList taskList( iCoeEnv->WsSession() );
TApaTask task = taskList.FindApp(uid );
if( task.Exists() ) //判断任务是否正在运行
_LIT8( KTestMsg, "CustomMessage" );
TUid msgUid( TUid::Uid( 1 ) );
task.SendMessage( msgUid, KTestMsg );


MCoeMessageObserver::TMessageResponse CXXXAppUi::HandleMessageL(TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid, const TDesC8& aMessageParameters)
_LIT( KFormatStr, "%x" );
TBuf<32> bufUid;
TBuf<32> bufPara;
bufUid.AppendFormat( KFormatStr, aMessageUid.iUid );
bufPara.Copy( aMessageParameters );
iEikonEnv->InfoWinL( bufUid, bufPara );
return MCoeMessageObserver::EMessageHandled;


      在Seires60的文档上说TApaTask:: SendMessage()发送的消息会被CEikAppUI::ProcessMessageL()处理,实际上如果我们在UI类中重新实现ProcessMessageL(),只会接受到KUidApaMessageSwitchOpenFileValue和KUidApaMessageSwitchCreateFileValue这两个消息,其它值的消息不会被传到ProcessMessageL()中。
This page was last modified on 15 December 2011, at 06:25.
142 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.