Answer a Call Tutorial

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

Steps

  1. create a new instance of [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony
  2. Use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]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 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::EVoiceLineStatusChange. Also pass it an empty [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]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 [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::AnswerIncomingCall(). You can only answer a call when the voice line status is Ringing([[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::EStatusRinging)
  4. pass the enumeration [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]CTelephony::EAnswerIncomingCallCancel to cancel the operation.

Answer a call example

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

class CClientApp : public CActive
    { 

private:
    CTelephony* iTelephony;
    CTelephony::TCallId iCallId;

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

private:
    /*
       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),
      iTelephony(aTelephony)
    {
    //default constructor
    }

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

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

void CClientApp::DoCancel()
    {
    iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
    }

Next actions

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 ([[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTelephony']]]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.