This is a tutorial on how you can integrate Zoom SDK for Android in your application. This is a step by step guide on how you can create an online meeting with Zoom SDK. Follow the article to integrate this into your own application. Let us start with the requirement first.
This is PART 1 int the series of tutorials. For PART 2 that contains how to retrieve the meeting ID and password, read PART 2 here.
We will need the ID and Password to join the meeting.
Feel free to correct any of the misinformation if you find in this post by commenting below.
Quick Navigation
Setup Zoom for creating meeting
Before we can actually proceed we are required to setup a couple of things. We need to create a zoom account itself for our use. Then we will be creating a app in the zoom account. This app will provide us with the API keys which will be required later for integrating Zoom into our own application.
Let us see what we need to do before creating a Zoom powered online meeting.
Creating a Zoom account
We must have a Zoom account before proceeding any further. Because we have to use Zoom’s API for creating and joining meetings. Head over to Zoom’s signup page and create an account and follow this article further, click here to signup with Zoom.
Creating API Keys for Zoom SDK Android
This part can be quite confusing for beginners. Not because of the fact that you are a beginner but because there are a whole lot of options available in the settings. Let us look at the image below:
First navigate to the app market place, click here to visit go to the marketplace. You will be greeted with a different screen from above. But the navigation bar will be same, from the picture click on the develop drop-down indicated by 1. And then click on the Build App indicated by 2 in the image. Then you will be seeing the screen same as above.
Naming our application
Our task now is to create an application so that we can get the API keys for our use.
Click on the create button in the card indicated by 3 to begin with Zoom app creation process. You will see a popup as shown below. Now that in place let us move forward.
Filling in details for application
Click create to proceed forward in creation process. Once you click create you will see a screen similar to one shown below. Fill in all the details and click continue at the bottom right.
Once you hit continue you will see App Credentials page like the image below. You need the SDK Key and SDK Secret highlighted below. This will be used later in our application, it will always be here so you can come back and check it later. Click continue to move forward.
Viewing created SDK keys
Status of Zoom application
Once you click continue in above screen. You will see the activation screen. Here you need not do anything. This is just the indicator for the application you just created.
And yes, you can deactivate the app from the activation screen shown below.
That concludes our app creation for Zoom SDK. We will see how we can integrate this into our application. If you have your android project ready, it’s good. If not now is the right time to setup your project to follow along.
Limitations of Zoom free account
By default we will have a FREE Zoom account, we can upgrade to PRO if we want. But this is beyond the scope of this article. Here I have listed some of the limitations of Zoom for free account.
- Zoom meeting length will only be maximum of 40 minutes.
- Only 100 people can join per session in online meeting.
Now that we have cleared things up let us proceed with our android implementation.
Setup Zoom SDK
Next we have to setup our application to use the SDK for video conferencing. There are a number of things we need to do before we dive into actual coding. We have to download the SDK from GitHub and add it into our project. Let us see what needs to be setup step by step.
Download Zoom SDK
To be able to use Zoom in our application we need to download the SDK provided by them.
Click to download the SDK or if you have problem downloading the zip. You can browse to the GitHub and browse through the repository by clicking here.
Add Zoom SDK to project
We have successfully downloaded the SDK from the GitHub at this point. Now we need to extract the .zip
file to a certain folder. We will then be including the SDK in our Android Studio project.
After successfully extracting the .zip file which includes the SDK. You will see two folders named commonlib
and mobilertc
. Both folders contain .aar
files which are mandatory to be included. You have to navigate to zoom-sdk-android-master
> zoom-sdk-android-master
, there will be our commonlib
and mobilertc
.
As seen in the image above the commonlib
and mobilertc
is only required as it contains the .aar
files which are Android libraries. Next we will use import the libraries in out project.
To import the .aar
library navigate to Android Studio’s File
> New
> New Module.
After that you will see the screen below select import .JAR/.AAR Package
select it and click next.
You will see the screen below navigate to where you extracted the zip file and select the commonlib.aar
file from the commonlib
folder.
Once clicking OK
on the above screen you will see a final screen with details filled just click finish
button to proceed. It is shown in the image below.
Repeat the above steps to include the mobilertc.aar
file located in mobilertc
directory. After that we have to use the libraries in our project by including them in app/build.gradle
file.
Add dependencies to project
After you have successfully added both commonlib.aar
and mobilertc.aar
. Add the following lines in app/build.gradle
‘s dependencies { }
block as shown below.
dependencies {
// your previous code ...
// just add the 2 lines below
implementation project(":commonlib")
implementation project(":mobilertc")
}
Code language: Groovy (groovy)
After that you have to sync the gradle
by clicking the popup on the top right. Yes, you can use the GUI way for including the project but I prefer this way because it’s really very short.
After the gradle
sync is successful follow along we will be setting up things.
INFO: The SDK zip already contains the runable project. Use the SDK Keys and SDK Secret from section above. If you just want to test the SDK you can run it too.
TECHENUM
Implementing Zoom SDK
Now that we have successfully included the libraries in our project. We now only need to worry about initializing the SDK and implementing features.
How we should implement the SDK are mentioned below. Just follow along to implement zoom SDK in android.
Add internet permission
Before we can do anything with the Zoom SDK we need the app to have the internet permission. Add the line below in your AndoridManifest.XML
and continue with the tutorial.
<uses-permission android:name="android.permission.INTERNET" />
Code language: HTML, XML (xml)
Adding Zoom SDK Keys
Here, I assume you have already finished creating the android project and ready for proceeding. To store our keys we will be creating a file Credentials.java
.
public class Credentials {
public static String SDK_KEY = "FsAu38plNJ46yId81lTvaGSRI1p2KyTWp4s1";
public static String SDK_SECRET = "----------------------------------";
public static String SDK_DOMAIN = "zoom.us";
}
Code language: Java (java)
Make sure to replace the keys with your own as shown in the section: VIEWING CREATED SDK KEYS.
Initialize Zoom SDK
Once we add the SDK Key
and SDK Secret
we need to initialize the SDK. Here is a code portion on how to execute the concept. I have intentionally left out code portion to make this even more clear.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// .....
initSdk()
}
/**
* Responsible for initializing the SDK
*/
private fun initSdk() {
val initParams = ZoomSDKInitParams().apply {
appKey = Credentials.SDK_KEY
appSecret = Credentials.SDK_SECRET
domain = Credentials.SDK_DOMAIN
}
ZoomSDK.getInstance().initialize(this, this, initParams)
}
}
Code language: Kotlin (kotlin)
We have created a method which initializes the SDK. This SDK will be invoked in the onCreate()
of the activity.
Login Zoom user
Before we can create any meetings we need to be logged in first. But even before we can login we need to wait until SDK is initialized. We have a callback for this built in. Let us implement the callback interface
. Make your interface implement the ZoomSDKInitializeListener
as below and implement the methods.
class MainActivity : AppCompatActivity(), ZoomSDKInitializeListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onZoomSDKInitializeResult(p0: Int, p1: Int) {
}
override fun onZoomAuthIdentityExpired() {
}
}
Code language: Kotlin (kotlin)
Once we have our interface setup we will create a login method to login to our account. See the code snippet below, we are continuing from above so leaving out the details.
class MainActivity : AppCompatActivity(), ZoomSDKInitializeListener {
...
private fun doLoginToZoom() {
val email = "[email protected]"
val password = "your_pass_word"
ZoomSDK.getInstance().loginWithZoom(email, password)
}
override fun onZoomSDKInitializeResult(p0: Int, p1: Int) {
doLoginToZoom()
}
...
}
Code language: Kotlin (kotlin)
Next we have to setup listeners before we can handle the response of our login. To do that we need to implement ZoomSDKAuthenticationListener
. We need to check the login status look at the snippet below.
Add the following line inside your initSdk()
mthod from above to make sure zoom sends back the response because are waiting for authentication respone.
private fun initSdk() {
// don't change the code keep it as it is
ZoomSDK.getInstance().addAuthenticationListener(this)
}
Code language: Kotlin (kotlin)
Let us handle the response from the authentication now. See the code below and modify the method.
override fun onZoomSDKLoginResult(p0: Long) {
when (p0.toInt()) {
ZoomAuthenticationError.ZOOM_AUTH_ERROR_SUCCESS -> {
Toast.makeText(this, "Login successful.", Toast.LENGTH_LONG).show()
}
ZoomAuthenticationError.ZOOM_AUTH_ERROR_USER_NOT_EXIST,
ZoomAuthenticationError.ZOOM_AUTH_ERROR_WRONG_PASSWORD -> {
Toast.makeText(this, "Username / Password do not match.", Toast.LENGTH_LONG).show()
}
}
}
Code language: Kotlin (kotlin)
The ZoomAuthenticationError
has the response codes for each possible response from the server. Let us understand what does each constant value mean.
ZoomAuthenticationError.ZOOM_AUTH_ERROR_SUCCESS
Code language: Kotlin (kotlin)
This is when the username and password matches and the user is logged in successfully.
ZoomAuthenticationError.ZOOM_AUTH_ERROR_USER_NOT_EXIST
Code language: Kotlin (kotlin)
This will be the response when the user doesn’t exist in the Zoom database.
ZoomAuthenticationError.ZOOM_AUTH_ERROR_WRONG_PASSWORD
Code language: Kotlin (kotlin)
This response is sent when the user exist but password do not match.
Why have we merged the latter two ? It is because the user doesn’t need to verbosely know about the user / password. Also it’s for security because the attacker will not know if there was an error with the user or the password.
Creating a meeting
Now that everything is setup correctly. We will see how to create a new meeting. The hard part is really over we just need to focus on the implementation of Zoom SDK in our Android application.
I have created a class with name MeetingHostHelper
. The class is to separate the logic of meeting creation. So that it will not clutter our main activity.
class MeetingHostHelper(
private val context: Context,
zoomSDK: ZoomSDK,
private val meetingStatusListener: MeetingStatusListener
) {
private val meetingService = zoomSDK.meetingService
fun createInstantMeeting(): Int {
}
}
Code language: Kotlin (kotlin)
I have a method already setup named createInstantMeeting
which will return an Int.
We need to create an interface too to get meeting status update. Create the interface anywhere in the project.
Here I have included the method in the MeetingHostHelper
like below.
class MeetingHostHelper(
private val context: Context,
zoomSDK: ZoomSDK,
private val meetingStatusListener: MeetingStatusListener
) {
private val meetingService = zoomSDK.meetingService
fun createInstantMeeting(): Int {
}
/**
* To get the status of meeting when the user clicks create.
* This is a listener
*/
interface MeetingStatusListener {
fun onMeetingFailed()
fun onMeetingRunning()
}
}
Code language: Kotlin (kotlin)
Also Read: Interface in OOP: Guide to Polymorphism and Callbacks
TECHENUM
Let us now see the implementation for createInstantMeeting()
.
fun createInstantMeeting(): Int {
if (meetingService == null) return -1 // should not be null; if null return -1
val opts = InstantMeetingOptions()
opts.no_driving_mode = true;
opts.no_invite = true;
opts.no_meeting_end_message = true;
opts.no_titlebar = true;
opts.no_bottom_toolbar = true;
opts.no_dial_in_via_phone = true;
opts.no_dial_out_to_phone = true;
opts.no_disconnect_audio = true;
opts.no_share = true;
meetingService.addListener { meetingStatus, errorCode, internalErrorCode ->
if (meetingStatus == MeetingStatus.MEETING_STATUS_FAILED) {
meetingStatusListener.onMeetingFailed()
} else if (meetingStatus == MeetingStatus.MEETING_STATUS_FAILED
&& errorCode == MeetingError.MEETING_ERROR_CLIENT_INCOMPATIBLE
) {
// meeting failed because the SDK version is too low upgrade the sdk
meetingStatusListener.onMeetingFailed()
} else {
meetingStatusListener.onMeetingRunning()
}
}
return meetingService.startInstantMeeting(context, opts)
}
Code language: Kotlin (kotlin)
Let us see how we can use it in our Activity
.
Create a Button
in your Activity
/ Fragment
. Set and in the listener we will be inserting the following code.
startMeeting.setOnClickListener {
MeetingHostHelper(
this,
ZoomSDK.getInstance(),
object : MeetingHostHelper.MeetingStatusListener {
override fun onMeetingFailed() {
Toast.makeText(this@MainActivity, "Could not host a meeting.", Toast.LENGTH_LONG).show()
}
override fun onMeetingRunning() {
Toast.makeText(this@MainActivity, "Created a meeting successfully.", Toast.LENGTH_LONG).show()
}
}).createInstantMeeting()
}
Code language: Kotlin (kotlin)
In the code above we have created a new instance for MeetingHostHelper
passing the Context
, ZoomSDK instance
and the MeetingStatusListener
for callback.
Finally we have invoked the createInstantMeeting()
on our instance.
I will be writing about how you can join meeting in another blog post.
Possible problems and solution
While running the application you might face some errors. I have listed out the solution to main 2 errors, read below.
#1 problem
If the min android SDK is below 21 the project will not compile and will result in build error.
The solution
Change the minSdkVersion
in app/build.gradle
to 21
.
#2 problem
If you don’t have the material design library included in your dependencies { }
block. You will find some error stating bottom sheet.
The solution
Add the following dependency in the app/build.gradle
file.
implementation "com.google.android.material:material:1.1.0"
Code language: Groovy (groovy)
#3 problem
You might encounter the following error while creating the instant meeting.
Didn't find class "androidx.localbroadcastmanager.content.LocalBroadcastManager"
The solution
Add the following dependency in you dependencies { }
block in the app/build.gradle
file.
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
Code language: Groovy (groovy)
Stay tuned for next post where I will be explaining how you can let other’s join into your hosted meeting.
UPDATE: Part 2 can be found here!
Happy CODING!
Also Read: Learning about encrypting files & folders on Ubuntu
TECHENUM
The link to working project, continue to GitHub.
Nicely explained and helpful article. Thanks for sharing
nice one! any tutorial how to join a meeting from android sdk ? thanks in advance
Thank you for reading. I will be adding part 2 of this tutorial within this week. Explaining how you can join the meeting. Stay tuned! 🙂
Part 2 has been published here : http://nepdev.xyz/zoom-sdk-android-learn-how-to-join-an-online-meeting/
onZoomSDKLoginResult this method is not overriding
Everything seems to be working fine I’ve checked it. Please look at line 123 of this file: MainActivity.kt. Also note that you have to implement the ZoomSDKAuthenticationListener interface, see line 12 of the file.
Please let me know if there is anything else.