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', 192.168.2.104 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
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 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
Callback function for processing incoming call is added. (line 295)
3. Outgoing call. line 387
New call is created with method Session.createCall().
CallOptions object with callee SIP username is passed to the method.
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 Call.call(). 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.