Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Example of Android application for audio calls

On the screenshot below the example is displayed when a call is established.

In the input field 'WCS URL', is the address of the WCS server.
In the input field 'Callee', 001 is the SIP username of the callee.

SIP connection is established/closed when Connect/Disconnect button is clicked.
Call is placed/terminated when Call/Hangup button is clicked, and put on hold/retrieve when Hold/Unhold button is clicked.

Work with code of the example

To analyze the code, let's take class of the phone-min example version with hash 4ed4c6d77, which can be downloaded with corresponding build

1. Initialization of the API. line 71


For initialization, object Сontext is passed to the init() method.

2. Connection to server.

Session for connection to server is created when Connect button is clicked. line 223

session = Flashphoner.createSession(sessionOptions);

Session is created with method createSession(), to which object SessionOptions (line 222) with URL of WCS server is passed.

Callback functions for session events are added (line 224)

  • onConnected() - will be called when connection is successfully established
  • onRegistered() - will be called when SIP registration is successfully established
  • onDisconnection() - will be called when connection is closed
session.on(new SessionEvent() {
    public void onConnected(final Connection connection) {
    public void onRegistered(final Connection connection) {
    public void onDisconnection(final Connection connection) {

Callback function for processing incoming call is added. (line 295)

session.on(new IncomingCallEvent() {
    public void onCall(final Call call) {

Method Session.connect() is called to establish connection with WCS server. line 345
Connection object (line 338) with parameters required for establishing SIP connection is passed to the method.


3. Outgoing call. line 387

New call is created with method Session.createCall().
CallOptions object with callee SIP username is passed to the method.

call = session.createCall(callOptions);

Callback functions, which make appropriate changes in controls of the interface, are added for processing call statuses (line 388).


Сallback functions are defined in CallStatusEvent object. (line 93).

Outgoing call is placed with method line 392;

4. Answering incoming call.

Incoming call is answered with method Call.answer().


5. Call hold.

The following methods are used to put call on hold and retrieve

6. Call hangup.

Method Call.hangup() is used to hang up call


7. Disconnection. line 358

Method Session.disconnect() is called to close connection to the server.

  • No labels