Initialize the client
VoiceClient is the main class used to interact with Android client SDK. Prior to usage, you have to initialize the client by providing an instance of the Android Context class.
At the top of the MainActivity class define client property that will hold the reference to the client and otherUser property that will hold the name of 2nd user (the user that call will be made to):
private lateinit var client: VoiceClient
private var otherUser: String = ""
Locate the onCreate method in the MainActivity class and initialize VoiceClient:
client = VoiceClient(this.application.applicationContext)
val config = VGClientConfig(ClientConfigRegion.US)
config.enableWebsocketInvites = true
client.setConfig(config)
NOTE: The enableWebsocketInvites flag on the client configuration should not be used in production. Enable push notifications to make sure you get incoming calls even when your application is in the background. See the push notifications guide for more information.
IDE will display a warning about the unresolved reference:

Put caret on the red text and press Alt + Enter to import the reference.
Now in the MainActivity class add helper method that hides all UI items:
private fun hideUI() {
val content = findViewById<LinearLayout>(R.id.content)
content.forEach { it.visibility = View.GONE }
}
Finally fill the body of two methods to allow user login. Please make sure to replace ALICE_JWT and BOB_JWT with the JWTs you created during a previous step:
private fun loginAsAlice() {
otherUser = "Bob"
client.createSession(ALICE_JWT) {
err, sessionId ->
when {
err != null -> {
hideUI()
connectionStatusTextView.visibility = View.VISIBLE
connectionStatusTextView.text = err.localizedMessage
}
else -> {
hideUI()
connectionStatusTextView.visibility = View.VISIBLE
connectionStatusTextView.text = "Connected"
startCallButton.visibility = View.VISIBLE
waitingForIncomingCallTextView.visibility = View.VISIBLE
}
}
}
}
private fun loginAsBob() {
otherUser = "Alice"
client.createSession(BOB_JWT) {
err, sessionId ->
when {
err != null -> {
hideUI()
connectionStatusTextView.visibility = View.VISIBLE
connectionStatusTextView.text = err.localizedMessage
}
else -> {
hideUI()
connectionStatusTextView.visibility = View.VISIBLE
connectionStatusTextView.text = "Connected"
startCallButton.visibility = View.VISIBLE
waitingForIncomingCallTextView.visibility = View.VISIBLE
}
}
}
}
NOTE Expiry time for the token was set to 6 hours so you will need to generate a new one if it is too old.
Build and Run
Press Ctrl + R buttons to build and run the app.
After successful user login you will see waiting for incoming call text and make a call button:

Making an app to app voice call
Make a voice call from an Android app to the same Android app installed on other device using the Android Client SDK.