SDK quickstart
Thanks to Agora’s intelligent and global Software Defined Real-time Network (Agora SD-RTN™), you can rely on the highest available video and audio quality.
This page shows the minimum code you need to integrate high-quality, low-latency Interactive Live Streaming features into your app using Video SDK.
Understand the tech
This section explains how you can integrate Interactive Live Streaming features into your app. The following figure shows the workflow you need to integrate this feature into your app.
To start a session, implement the following steps in your app:
-
Retrieve a token: A token is a computer-generated string that authenticates a user when your app joins a channel. In this guide you retrieve your token from Agora Console. To see how to create an authentication server for development purposes, see Implement the authentication workflow. To develop your own token generator and integrate it into your production IAM system, read Token generators.
-
Join a channel: Call methods to create and join a channel; apps that pass the same channel name join the same channel.
Prerequisites
In order to follow this procedure you must have:
- Android Studio 4.1 or higher.
- Android SDK API Level 24 or higher.
- A mobile device that runs Android 4.1 or higher.
-
A computer with Internet access.
Ensure that no firewall is blocking your network communication.
Project setup
To install the Video SDK reference app on your development device:
Agora supplies a single GitHub reference repository. This runnable and testable repo contains all the code used in this Video SDK documentation. To create a Video SDK development environment:
-
Clone the Video SDK reference app to
<samples-root>
on your development environment:Navigate to your
<samples-root>
folder and run the following command: -
Open the reference app in Android Studio:
From the File menu select Open... then navigate to
<samples-root>/video-sdk-samples-android/android-reference-app
and click OK. Android Studio loads the project and Gradle sync downloads the dependencies.
You are ready to implement Interactive Live Streaming features using the Android reference app.
Implement a client for Interactive Live Streaming
When a user opens the app, you initialize Agora Engine. When the user taps a button, the app joins or leaves a channel. When another user joins the same channel, their video and audio is rendered in the app. This simple workflow enables you to concentrate on implementing Agora features and not UX bells and whistles.
Best practice is to separate the Interactive Live Streaming workflows from your UI implementation. The Video SDK
sample project implements Interactive Live Streaming logic in the
AgoraManager
class.
This class encapsulates the RTCEngine
instance and core functionality as illustrated by the excerpts below:
-
Import the Video SDK classes and interfaces:
-
Declare variables to create an Agora Engine instance and join a channel:
-
Configure an Agora Engine instance and set up an event handler:
-
Handle and respond to Agora Engine events:
-
Render video from a remote user in the channel:
-
Render video from the local user in the channel:
-
Join a channel to start Interactive Live Streaming:
-
Leave the channel when the local user ends the call:
-
Clean up the resources used by the app:
Test your implementation
Agora recommends you run this project on a physical mobile device, as some simulators may not support the full features of this project. To ensure that you have implemented Interactive Live Streaming in your app:
-
Generate a temporary token in Agora Console.
-
Configure the web demo you use to connect to your app:
In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.
-
Configure the project:
In
agora-manager/res/raw/config.json
, Replace:appId
- with your app ID from Agora Console.channelName
- with the name of a channel you want to join.rtcToken
- with a valid temporary token for thechannelName
.
-
Run the Android reference app:
-
In Android Studio, connect a physical Android device to your development machine.
-
Click Run to start the app.
A moment later you see the project installed on your device. If this is the first time you run the project, you need to grant microphone and camera access to your app.
-
From the main screen of the app, choose Interactive Live Streaming from the dropdown and then select SDK Quickstart.
-
-
Join a Channel:
Reference
This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.
-
Downloads shows you how to install Video SDK manually.
-
To ensure communication security in a test or production environment, use a token server to generate token is recommended to ensure communication security, see Implement the authentication workflow.
- For a more complete example, see the open source Interactive Live Streaming example project on GitHub.