Kotlin
Fetch the Conversation
Inside MainActivity class add the conversation property:
private var conversation: NexmoConversation? = null
Update body of the getConversation() method:
private fun getConversation() {
client.getConversation(CONVERSATION_ID, object : NexmoRequestListener<NexmoConversation?> {
override fun onSuccess(conversation: NexmoConversation?) {
this@MainActivity.conversation = conversation
}
override fun onError(apiError: NexmoApiError) {
conversation = null
Toast.makeText(this@MainActivity, "Error: Unable to load conversation", Toast.LENGTH_SHORT)
}
})
}
Please make sure to replace CONVERSATION_ID with the conversation id you created during a previous step.
The above method loads the conversation using client.getConversation and then it loads all events from the conversation.
Note: Conversation id is retrieved from Config.CONVERSATION_ID provided in the previous step.
Creating an Android chat app
Create a Android application that enables users to message each other using the Android Client SDK and Kotlin.
手順
1
Introduction to this task2
Prerequisites3
Create a Vonage Application4
Create a conversation5
Create the users6
Add users to the conversation7
Generate JWTs8
Create an Android project9
Add permissions10
Build main screen11
Initialize the client12
Fetch the conversation13
Fetch conversation events14
Send a message15
Receive new messages16
What's next?