Start a Video Call using UI Kit
Real-time video chatting immerses people in the sights and sounds of human connections. This keeps your users engaged for longer with your app. Agora Video SDK makes it easy for you to manage video calls and interactive live streaming events in an app. Agora UIKit is a library that combines Agora real-time engagement functionality into a customizable user interface. Have another coffee, we have done all the work for you.
This page shows the minimum code you need to add a real-time engagement interface into your app using Agora UIKit.
Understand the tech
The following figure shows the workflow you integrate into your app in order to achieve Video Call functionality using Agora UIKit.
To start a call using Agora UIKit, you implement the following steps in your app:
-
Join a channel:
The
join
command joins the channel, publishes the local audio and video streams to Agora and handles audio and video for anyone else who joins the call in a default UI.
Yes, you read that right. After initializing an AgoraVideoViewer
instance, you manage a call with one line of code.
Prerequisites
-
Android Studio 4.1 or later.
-
Android SDK API Level 24 or higher.
-
A computer that can access the Internet.
Ensure that no firewall is deployed in your network environment, otherwise the project fails.
-
A physical Android device to run your app on.
-
A valid Agora account and an Agora project.
Project setup
In order to create the environment necessary to integrate Video Call into your app, do the following:
-
For new projects, in Android Studio, create a Phone and Tablet Android project with an Empty Activity using Kotlin. Set Minimum SDK to API 24.
After creating the project, Android Studio automatically starts gradle sync. Ensure that the sync succeeds before you continue.
-
Integrate Agora UIKit into your project:
-
In
Gradle Scripts/settings.gradle(Project Settings)
, add the jitpack repository. For example: -
In
Gradle Scripts/build.gradle( Module: <projectname> )
: Add the Agora UIKit dependency. For example: -
Find the pre 4.x version of Agora UIKit and replace
version
with the one you want to use. For example:2.0.6
. -
Sync Gradle and import Agora UIKit.
-
Add permissions for network and device access.
In
/app/Manifests/AndroidManifest.xml
, add the following permissions after</application>
:
-
Implement a client for Video Call
This section shows how to use Agora UIKit to implement Video Call into your app step-by-step.
To integrate real-time video in a ready-made user interface:
-
Import the Agora classes.
In
/app/java/com.example.<projectname>/MainActivity
, add the following lines afterimport android.os.Bundle
: -
Create the variables that you use to initiate and join a channel.
In
/app/java/<project.package.name>/MainActivity
, add the following lines afterAppCompatActivity {
: -
Create a function that initializes an
AgoraVideoViewer
instance and joins a channel.In
/app/java/com.example.<projectname>/MainActivity
, add the following lines after the variables: -
Start your app
In
/app/java/com.example.<projectname>/MainActivity
, updateonCreate
to runinitializeAndJoinChannel()
when the app starts. For example:
Test your app
To check that your code works, use an online demo to make a video call to your app. To test real-time engagement with your app:
-
Generate a temporary token in Agora Console.
-
In your browser on another device, navigate to the Basic Communication sample app, update App ID, Channel and Token with the values for your temporary token, then click JOIN.
-
In Android Studio, in
/app/java/com.example.<projectname>/MainActivity
, updateappId
,channelName
andtoken
with the values for your temporary token. -
Run your app on a device.
Your app opens in an Android device and connects to the channelName
you opened in the Web app. You now have the golden opportunity of talking to yourself using Video Call in a complete UI created using Agora UIKit.