Basic: Making a Video Call

There is a new release of the Developer Center! If you'd like to check it out, please click  here

Basic: Making a Video Call

Getting Started

Step 1: Prepare the Environment

  1. Download the Video SDK.
  2. Hardware and software requirements:
    • Android 4.1 and later devices with audio and video support
    • Android SDK API 16 or later
    • Android Studio 2.0 or later
  3. Before accessing Agora’s services, make sure that you have connected to the ports and whitelisted the domains as specified in Firewall Requirements .

Step 2: Add the SDK

  1. Copy the following libraries from the libs folder according to your needs.

    • agora-rtc-sdk.jar (mandatory)
    • armeabi-v7a/
    • x86/
    • arm64-v8a
    • include


    When copying the libraries to the libs folder in the targeted path, if there is any Chinese character in the path, the sample code will not be compiled successfully, and will display random ASCII code in the error message.

  2. Put the required libraries in the correct libs path according to the settings in the build.gradle file.

  3. Specify the directory of the so file in the build.gradle file as the path of the libs folder in step 2.


Step 3: Configure the NDK

If the following error displays, it means that the NDK is not installed.


Download the NDK from the Android developer website, and put it in the Android location, for example,


Step 4: Add the Permissions

The following permissions are required in the AndroidManifest.xml file for your application when deployed:

  • <uses-permission android:name=”android.permission.INTERNET” />
  • <uses-permission android:name=”android.permission.RECORD_AUDIO” />
  • <uses-permission android:name=”android.permission.CAMERA” />
  • <uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” />
  • <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />

Step 5: Synchronize with the Project Files

Click Sync Project With Gradle Files until the synchronization is complete.


Step 6: Obfuscate the Code

Add the following line to obfuscate the code:

-keep class io.agora.**{*;}

Scenario 1: Making a Video Call

  1. Get an App ID, refer to Getting an App ID.
  2. Initialize RtcEngine, and fill in the App ID, refer to Create an RtcEngine Object (create).
private void initializeAgoraEngine() {
    try {
        mRtcEngine = RtcEngine.create(getBaseContext(), getString(R.string.agora_app_id), mRtcEventHandler);
    } catch (Exception e) {
        Log.e(LOG_TAG, Log.getStackTraceString(e));

        throw new RuntimeException("NEED TO check rtc sdk init fatal error\n" + Log.getStackTraceString(e));
  1. Set the video profile, refer to Set the Video Profile (setVideoProfile).
private void setupVideoProfile() {
    mRtcEngine.setVideoProfile(Constants.VIDEO_PROFILE_360P, false);
  1. Set the local video, refer to Set the Local Video View (setupLocalVideo).
private void setupLocalVideo() {
    FrameLayout container = (FrameLayout) findViewById(;
    SurfaceView surfaceView = RtcEngine.CreateRendererView(getBaseContext());
    mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_ADAPTIVE, 0));
  1. Join a channel, refer to Join a Channel (joinChannel).
private void joinChannel() {
    mRtcEngine.joinChannel(null, "demoChannel1", "Extra Optional Data", 0); // if you do not specify the uid, Agora will assign one.
  1. Set the remote video, refer to Set the Remote Video View (setupRemoteVideo).
private void setupRemoteVideo(int uid) {
    FrameLayout container = (FrameLayout) findViewById(;

    if (container.getChildCount() >= 1) {

    SurfaceView surfaceView = RtcEngine.CreateRendererView(getBaseContext());
    mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_ADAPTIVE, uid));

    View tipMsg = findViewById(;
  1. Hang up/End a call, refer to Leave a Channel (leaveChannel).
private void leaveChannel() {

The following APIs are related to making your first video call:


After joining a channel, the SDK turns on the camera by default, and you can call Start a Video Preview (startPreview) to enable the preview function. You can also call Disable the Video Mode (disableVideo) to switch to voice-only mode.

You can now start a one-to-one or group video call. The difference between a one-to-one and group call is the number of people joining the channel.

Scenario 2: Implement other Functions

The following functions can be implemented in a voice call:

Agora will provide the API call sequences and sample code for the following functions in the future. For now, see Video Call API:

  • Voice and video conference
  • Image control
  • Send text messages
  • Capture video data
Is this page helpful?