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:
private lateinit var client: VoiceClient
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 below client initialization code add the code to login the user. Please make sure to replace ALICE_JWT with the JWT you created during a previous step:
client.createSession("ALICE_JWT") {
err, sessionId ->
when {
err != null -> {
connectionStatusTextView.text = err.localizedMessage
startCallButton.visibility = View.INVISIBLE
endCallButton.visibility = View.INVISIBLE
}
else -> {
connectionStatusTextView.text = "Connected"
startCallButton.visibility = View.VISIBLE
endCallButton.visibility = View.INVISIBLE
}
}
}
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.
If the session is correct started we display the start and end call buttons, otherwise we will hide these buttons and display the returned error message.
Build and Run
Press the Ctrl + R keys to build and run the app again. After successful login you will see the START CALL button:

Making an in-app voice call
Make a voice call from a android app to a phone using the Android Client SDK.