How To Implement Video Call on Android with Two Lines of Code

Introducing a video calling feature to your application adds a powerful way for your users to communicate and interact with each other.

If you want to include video call in your application but don’t want to go through all the heavy lifting of reading the documentations and debugging the APIs, or if you just want to build a proof-of-concept (POC) application within a limited timeline, please continue reading this blog. In this blog, I will demonstrate how to add a video call feature in your application using only 2 lines of code.

Prerequisites

  1. Agora.io account
  2. Android Studio and 2 physical Android devices

Overview

In this blog post, I’m going to use the Agora Android UIKit to achieve the video call functionality. The Agora Android UIKit is a wrapper of the Agora Video SDK with a pre-designed UI layer. Using that, you don’t need to spend hours of work on the UI design for the video call and the implementation on video call logic. They are all handled in the SDK.

Implement the SDK

implementation'io.agora.uikit:agorauikit:2.0.1'
You can check the Agora Android UIKit GitHub code for more information.

Add Permissions

Then, add permissions in your AndroidManifest file.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Start Video Call

Last, add these 2 lines in your activity’s onCreate method.
AgoraRTC.instance().bootstrap(this, "appID", "channel");
setContentView(R.layout.group_template);
Follow this article to get the AppID. You can change the channel to your own channel name. The group_template contains the pre-designed UIs for the video call. You can check the .xml file to see the details of the UI design.
That’s all you need to do to start a video call!

Build and Test on Device

Now let’s run our application!

In Android Studio, make sure your Android device is plugged in, and click Run.

Done!

Congratulations! You just added the video call functionality in your app!
Thank you for following along. In my next blog post, I’m going to demonstrate how to customize Agora Android UIKit to fit different use cases. Stay tuned! Here is the email address for any of the questions you might have: devrel@agora.io.

Want to build Real-Time Engagement apps?

Get started with 10,000 free minutes today!

If you have questions, please call us at 408-879-5885. We’d be happy to help you add voice or video chat, streaming, and messaging into your apps.


Stay inspired by accessing all RTE2020 session recordings. Gain access to innovative Real-Time-Engagement content and start innovating today.