How to Build a Video Calling Android App with Jitsi Meet SDK?
Last Updated :
12 Sep, 2024
Video Calling has become a most demanding feature in many social media apps like WhatsApp, Instagram, Facebook, etc. Not only this but also there are some other applications available for providing only this feature to connect people all over the world with each other like Duo. Hence, this gives us an idea about the importance of video calling. So in this article, we will develop our own Video Calling application using Jitsi. Now, without wasting further time let's look at the implementation of this video-callingcall application in Android.
What we are going to build in this article?
In this article, we will develop a sample application that will contain an EditText and a Button in its MainActivity. Using EditText we will name a room for us to video call and after that, by clicking the Button we will join that room and a new activity will open by the name of our created room, and finally, by using this activity we will do video calling. A sample video is given below to get an idea about what we are going to do in this article.
Note that we are going to implement this project using the Java language.
Step by Step Implementation of Video Calling Application using Jitsi Meet SDK
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Note that select Java as the programming language. Select the minimum SDK 21 or higher.
Step 2: Add Jitsi maven repository
Now, go to the root settings.gradle.kts(Project) and add these lines at the end of repositories below the repository() inside the dependencyResolutionManagement{ } section.
maven {
url = uri("https://github.com/jitsi/jitsi-maven-repository/raw/master/releases")
}
maven {
url = uri("https://maven.google.com")
}
Here is what the settings.gradle.kts should look like:
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url = uri("https://github.com/jitsi/jitsi-maven-repository/raw/master/releases")
}
// Google Maven Repository
maven {
url = uri("https://maven.google.com")
}
}
}
Sync the changes.
Step 3: Add dependency
Now, Navigate to the Gradle Scripts > build.gradle(Module: app) add the below dependency in the dependencies section.
implementation("org.jitsi.react:jitsi-meet-sdk:10.1.2") { isTransitive = true }
Sync the changes again. This will take some time, so be patient.
Step 4: Working with the activity_main.xml file
Now it’s time to design the layout of the application. So for that go to the app >res > layout > activity_main.xml and paste the below-written code in the activity_main.xml file.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<!--EditText for taking input room name from user-->
<EditText
android:id="@+id/conferenceName"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_margin="12dp"
android:hint="Enter room name" />
<!--Button for creating a room for video
calling by it's clicking event-->
<!--When clicking event occur on button
then onButtonClick method will call -->
<Button
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_margin="12dp"
android:background="#0F9D58"
android:onClick="onButtonClick"
android:text="Join"
android:textColor="#FFFFFF" />
</LinearLayout>
Step 5: Working with the MainActivity.java file
Go to the app > java > package name > MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
MainActivity.java
package com.ishaanbhela.meetingapp;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import org.jitsi.meet.sdk.JitsiMeetActivity;
import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
import java.net.MalformedURLException;
import java.net.URL;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
public void onButtonClick(View view) throws MalformedURLException {
// initialize editText with method findViewById()
// here editText will hold the name of room which is given by user
EditText editText = findViewById(R.id.conferenceName);
// store the string input by user in editText in
// an local variable named text of string type
String text = editText.getText().toString();
// if user has typed some text in
// EditText then only room will create
if (text.length() > 0) {
// creating a room using JitsiMeetConferenceOptions class
// here .setRoom() method will set the text in room name
// here launch method with launch a new room to user where
// they can invite others too.
JitsiMeetConferenceOptions options
= new JitsiMeetConferenceOptions.Builder()
.setRoom(text)
.setFeatureFlag("welcomepage.enabled", false)
.setAudioMuted(true)
.setVideoMuted(true)
.build();
JitsiMeetActivity.launch(this, options);
}
}
}
That’s all, now the video calling application is ready to install on the device. Here is what the output of the application looks like.
Output: Run on a Physical Device
GitHub Link: For further help go through this repository.