You can use the application architecture services of Symbian OS to communicate between applications. The main classes used include: tapatasklist and tapatask.
Tapatasklist: used to access a running task on a device.
Tapatask: indicates a running task in the device, which is identified by the window group associated with the program.
Sending Message end: Use tapatasklist to find the task waiting to receive messages. tapatasklist: findapp () provides two overloaded versions. You can use the program title or the program UID to find the task. After receiving the message, you can send the message through the tapatask: sendmessage (). It has two parameters: the first parameter is used to identify the message, and the second parameter is a reference to the descriptor, it can be used to provide additional information for different messages.
Tuid UID (tuid: UID (0x 01_c 9d3 ));
Tapatasklist tasklist (icoeenv-> wssession ());
Tapatask task = tasklist. findapp (UID );
If (task. exists () // judge whether the task is running
{
_ Lit8 (ktestmsg, "custommessage ");
Tuid msguid (tuid: UID (1 ));
Task. sendmessage (UID, ktestmsg );
}
Receive message: mcoemessageobserver is the interface class for processing messages from the window server, because ceikappui has inherited from mcoemessageobserver, therefore, we only need to reproduce the unique member function handlemessagel () that implements mcoemessageobserver in our UI class to process received messages:
Mcoemessageobserver: tmessageresponse cxxxappui: handlemessagel (tuint32 aclienthandleoftargetwindowgroup, tuid amessageuid, const tdesc8 & amessageparameters)
{
_ Encode (kformatstr, "% x ");
Tbuf <32> bufuid;
Tbuf <32> bufpara;
Bufuid. appendformat (kformatstr, amessageuid. iuid );
Bufpara. Copy (amessageparameters );
Ieikonenv-> infowinl (bufuid, bufpara );
Return mcoemessageobserver: emessagehandled;
}
Supplement:
In the seires60 document, the message sent by tapatask: sendmessage () will be processed by ceikappui: processmessagel (). In fact, if we re-implement processmessagel () in the UI class (), only messages of kuidapamessageswitchopenfilevalue and kuidapamessageswitchcreatefilevalue are received. Messages of other values are not transmitted to processmessagel.