Avaya Client SDK

< Back to Package Overview

Answering an Audio Call

Using the Avaya Client SDK, you can easily integrate the ability for users of your application to make and receive audio or video calls.

To receive and answer an incoming audio call, you must complete the following activities.

  • Implement the call service listener to monitor for call service events
  • Accept the incoming call

Implement the call service listener

In order to get notifications for any incoming calls, your application can define an object that implements the CallServiceListener interface and add this listener object to the CallService object to receive call service notifications.

class AppCallServiceHandler implements CallServiceListener
{
    @Override
    public void onIncomingCallReceived(CallService callService, Call call) {
        // Called to report that there is an incoming call. 
        // Add code here to handle this incoming call, eg, 
        // update UI to alert user, provide options for handling 
        // the call, ... etc.
    }

    @Override
    public void onCallRemoved(CallService callService, Call call) {
        // Called to report that the call has been removed before 
        // answer.
        // Add code here to handle the removed call, eg, 
        // update UI to remove the call... etc.
    }

    ....
};

You can instantiate a call service handler (AppCallServiceHandler) and add it as a listener to the call service.

AppCallServiceHandler callServiceHandler = new AppCallServiceHandler();
CallService callService = mUser.getCallService();
callService.addListener(callServiceHandler);

When there is an incoming call, the CallServiceListener.onIncomingCallReceived() function is called with a Call object in the arguments. You can instantiate a call handler and add that as a listener to this call object for handling subsequent call events.

Answer the incoming call

To answer the incoming call, you can call the accept() function on the incoming call object.

call.accept();