Skip to main content
Version: 0.1.x

Start or Join Meeting - Android

After the successful installation of VideoSDK, the next step is to integrate VideoSDK features with your webApp/MobileApp.

To Communicate with other participant's audio or video call, you will need to join the meeting.

This guide will provide an overview of how to configure, initialize and join a VideoSDK meeting.

1. Configuration

To configure a meeting, you will need generated token and meetingId, we had discussed in Server Setup. This code snippet calls API from local server

Scenario 1 - Suppose you don't have any meetingId, you can simply generate meetingId by invoking create-meeting API.

Scenario 2 - Suppose you have meetingId, now you don't have to call create-meeting API to generate meetingId, instead you can call validate-meeting API to validate meetingId.

Token generation API is necessary for both scenario.

package live.videosdk.rtc.android.java;

import com.androidnetworking.AndroidNetworking;
import com.androidnetworking.error.ANError;
import com.androidnetworking.interfaces.JSONObjectRequestListener;
import org.json.JSONException;
import org.json.JSONObject;

class JoinActivity : AppCompatActivity() {
private val apiServerUrl = "http://localhost:9000"

// ...
// onCreate() and other methods
private fun getToken(@Nullable meetingId: String?) {
AndroidNetworking
.get("$apiServerUrl/get-token")
.build()
.getAsJSONObject(
object : JSONObjectRequestListener {
override fun onResponse(response: JSONObject) {
try
{
token = response.getString("token")
if (meetingId == null) {
createMeeting(token)
} else {
joinMeeting(token, meetingId)
}
} catch (e: JSONException) {
e.printStackTrace()
}
}

override fun onError(anError: ANError) {
anError.printStackTrace()
}
}
)
}

private fun createMeeting(token: String) {
AndroidNetworking
.post("$apiServerUrl/create-meeting")
.addBodyParameter("token", token)
.build()
.getAsJSONObject(
object : JSONObjectRequestListener {
override fun onResponse(response: JSONObject) {
try {
// final String meetingId = response.getString("meetingId");

// Intent intent = new Intent(JoinActivity.this, MainActivity.class);
// intent.putExtra("token", token);
// intent.putExtra("meetingId", meetingId);

// startActivity(intent);
} catch (e: JSONException) {
e.printStackTrace()
}
}

override fun onError(anError: ANError) {
anError.printStackTrace()
}
}
)
}

private fun joinMeeting(token: String, meetingId: String) {
AndroidNetworking
.post("$apiServerUrl/validate-meeting/{meetingId}")
.addPathParameter("meetingId", meetingId)
.addBodyParameter("token", token)
.build()
.getAsJSONObject(
object : JSONObjectRequestListener {
override fun onResponse(response: JSONObject) {
// Intent intent = new Intent(JoinActivity.this, MainActivity.class);
// intent.putExtra("token", token);
// intent.putExtra("meetingId", meetingId);

// startActivity(intent);
}

override fun onError(anError: ANError) {
anError.printStackTrace()
}
}
)
}
}

2. Initialization

After configuration, you will have to Initialize

meeting by providing name, meetingId, micEnabled, webcamEnabled & maxResolution.

NOTE : For React & React native developer, you have

to be familiar with hooks concept. You can understand hooks concept on React Hooks.

import live.videosdk.rtc.android.VideoSDK;
import live.videosdk.rtc.android.Meeting;

class MainActivity : AppCompatActivity() {
private var meeting: Meeting? = null

override fun onCreate(savedInstanceState: Bundle?) {
// Configure parameters
val token = intent.getStringExtra("token")
val meetingId = intent.getStringExtra("meetingId")
val participantName = "John Doe"
val micEnabled = true
val webcamEnabled = true
val paticipantId="demo@123" // If you passed `null` then SDK will create an Id by itself and will use that id.
val mode="CONFERENCE"

// Configure authentication token
VideoSDK.config(token)

// create a new meeting instance
meeting = VideoSDK.initMeeting(
this@MainActivity,
meetingId,
participantName,
micEnabled,
webcamEnabled,
paticipantId,
mode,
null
)
}
}

3. Join

After configuration & initialization, the third step is to call join() to join a meeting.

After joining, you will be able to Manage Participant in a meeting.

// After receiving mic and webcam access permissions
// join the meeting
meeting!!.join()

Events

Following events are emitted on the meeting when it is successfully joined.

private final MeetingEventListener meetingEventListener = new MeetingEventListener() {
override fun onMeetingJoined() {
Log.d("#meeting", "onMeetingJoined()")
}

override fun onParticipantJoined(participant: Participant) {
Log.d("#meeting", participant.displayName + " left");
}
}

Got a Question? Ask us on discord