Answer a Call Tutorial

This tutorial describes how to detect and answer an inbound call with the telephony API for applications.

  1. create a new instance of CTelephony

  2. Use CTelephony::NotifyChange() to detect changes in the voice line's status. NotifyChange() can be used to detect a variety of changes, but in this case you are only interested in the status of the voice line. Pass a notification event, in this case CTelephony::EVoiceLineStatusChange . Also pass it an empty CTelephony::TCallStatusV1Pckg . Possible status values are Idle, Ringing, On-Hold. When the voice line status is Ringing( CTelephony::EStatusRinging ) there is an incoming voice call to be answered.

  3. answer a call with CTelephony::AnswerIncomingCall() . You can only answer a call when the voice line status is Ringing( CTelephony::EStatusRinging )

  4. pass the enumeration CTelephony::EAnswerIncomingCallCancel to cancel the operation.

Answer a call example

       #include <e32base.h>
#include <Etel3rdParty.h>

class CClientApp : public CActive

    CTelephony* iTelephony;
    CTelephony::TCallId iCallId;

    CClientApp(CTelephony* aTelephony);
    void SomeFunction();

       These are the pure virtual methods from CActive that  
       MUST be implemented by all active objects
    void RunL();
    void DoCancel();

CClientApp::CClientApp(CTelephony* aTelephony)
    : CActive(EPriorityStandard),
    //default constructor

void CClientApp::SomeFunction()
    iTelephony->AnswerIncomingCall(iStatus, iCallId);

void CClientApp::RunL()
       {} // The call has been answered successfully;
          // iCallId contains the call's ID, needed when controlling the call.

void CClientApp::DoCancel()

This describes how to answer a second call while another is in progress.

  1. Put the first call on hold.

    This is the same as holding a call in Call Hold Tutorial .

    If the other call was not dialled or answered by you then you cannot control it, and so you cannot put it on hold. If it is not on hold already ( CTelephony::EStatusHold ) then you cannot answer the call.

  2. Answer the second call.

    This is the same as answering the first call. AnswerIncomingCall() will return a different call ID from the first call.

  3. If the operation fails, remember to resume the original call.

As a result, the first call is on-hold and the second call is active.