Avaya Client SDK

< Back to Package Overview

Making 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 make an audio call, you must complete the following activities:

  • Create a call object and initialize the details for the call
  • Implement the call listener to monitor for call progress events
  • Start the call

Create a call object

Creating a Call object allows you to set various properties for the call before the call is actually placed.

The Call object is created from the CallService.

CallService callService = mUser.getCallService();
Call call = callService.createCall();

You can specify the phone number to dial by setting the remote address.

call.setRemoteAddress(callNumber);

Implement the call listener

To monitor call progress events, the CallListener interface provided by the Call object can be used. This interface provides notification as the call state changes.

Your application can define an object that implements the CallListener interface and can add it to the Call object to receive callback notifications.

class AppCallHandler implements CallListener
{
    @Override
    public void onCallStarted(Call call) {
        // Called to report that call has started (ie, call is in progress).
        // Add code here to update the UI as appropriate.
    }

    @Override
    public void onCallRemoteAlerting(Call call, boolean b) {
        // Called to report that an outgoing call is ringing at the far end.
        // Add code here to update the UI as appropriate.
    }

    @Override
    public void onCallEstablished(Call call) {
        // Called to report that an outgoing call has been established 
        // (ie, far end has answered and speechpath has been established).
        // Add code here to update the UI as appropriate.
    }

    @Override
    public void onCallEnded(Call call, CallEndReason endReason) {
        // Called to report that call has ended.
        // Add code here to update the UI as appropriate.
    }

    @Override
    public void onCallFailed(Call call, CallException e) {
        // Called to report that call has failed and the failure reason
        // is described in the CallException code.
        // Add code here to update the UI as appropriate.
    }

    ....
};

You can instantiate an application call handler (AppCallHandler) and add that as a listener to the call.

AppCallHandler callHandler = new AppCallHandler();
call.addListener(callHandler);

Start the call

Once a call listener has been added, you can call the start() method on the Call object. Call progress events will be provided through the CallListener interface.

call.start();

End the call

To terminate the call, you can call the end() method on the Call object.

call.end();

The onCallEnded() callback event is sent to the call listener when the call has been ended. You can use this event to update the UI of your application.