Kotlin

Place a call

Finally, lets setup the ability to place call from this application.

In the onCreate function, add the RTC Hangup listener:

This call listener will handle when the other person on the call hangs up. When this happens we reset the app to its original state.

Add the start call click listener code in onCreate too:

To start the call after pressing start call button add the startCall method inside Mainctivity class:

The above method starts the call.

Webhooks

As you proceed with placing the call, please switch to the terminal and notice the /voice/answer endpoint being called to retrieve the NCCO:

Also, as the call progresses through various stages, /voice/event is being sent events:

NOTE: As the call is completed, events will also contain duration and pricing information.

The end call button was shown to reflect the current state of the call:

End call