Integrating PopinAndroidSDK for Video Calls
This guide explains how to integrate and use the PopinAndroidSDK library to enable video calling features in your Android application. The SDK is lightweight, easy to integrate, and provides pre-built classes such as PopinConnectingDialog
for managing connection states.
✅ Prerequisites
Android Studio installed
Minimum SDK version supported by PopinAndroidSDK
A valid Popin token
Step 1: Add PopinAndroidSDK to Your Project
1.1 Add JitPack to settings.gradle
settings.gradle
Open your project’s settings.gradle
file and add the JitPack repository:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
1.2 Add SDK Dependency in build.gradle
build.gradle
In your app/build.gradle
file, add the Popin SDK dependency:
dependencies {
implementation 'com.github.Springr-Creatives:PopinAndroidSDK:1.5.9'
}
1.3 Update AndroidManifest.xml
AndroidManifest.xml
Insert the following into your AndroidManifest.xml
:
<meta-data
android:name="to.popin.androidsdk.POPIN_TOKEN"
android:value="<your_token_here>" />
<activity
android:name="to.popin.androidsdk.call.CallActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTask"
android:showWhenLocked="true"
android:supportsPictureInPicture="true" />
Replace <your_token_here>
with your actual Popin token.
Step 2: Initialize Popin in Your App
Initialize Popin SDK in your main activity, typically inside the onCreate()
method:
Popin.init(MainActivity.this, "test_user", "9876543210");
This prepares the SDK to handle video call connections.
Step 3: Add a Call Button in XML
Define a button in your layout file (activity_main.xml
) to trigger the video call:
<Button
android:id="@+id/buttonCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Call"/>
Step 4: Implement Button Click to Start Call
In your MainActivity.java
, add the logic to initiate a call when the button is clicked:
Button buttonCall = findViewById(R.id.buttonCall);
buttonCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Show connecting dialog
PopinConnectingDialog cdd = new PopinConnectingDialog(MainActivity.this);
cdd.show();
// Start the video call
Popin.getInstance().startCall(new PopinEventsListener() {
@Override
public void onCallStart() {
// Call is starting to connect
}
@Override
public void onQueuePositionChanged(int i) {
// Update UI if the user is in a queue
}
@Override
public void onAllExpertsBusy() {
// All experts are busy, dismiss the dialog
cdd.dismiss();
}
@Override
public void onCallConnected() {
// Call successfully connected
cdd.dismiss();
}
@Override
public void onCallFailed() {
// Call failed to connect
cdd.dismiss();
}
@Override
public void onCallDisconnected() {
// Handle call disconnection
}
});
}
});
Step 5: Understanding Call Events
Here’s a breakdown of the available PopinEventsListener
callbacks:
onCallStart()
Called when the connection process begins.
onQueuePositionChanged(int i)
Invoked if the call is in a queue; use it to update the user interface.
onAllExpertsBusy()
Called when all experts are currently unavailable.
onCallConnected()
Triggered once the call is successfully connected.
onCallFailed()
Triggered if the call could not be connected.
onCallDisconnected()
Called when the call ends or is disconnected.
Step 6: Using PopinConnectingDialog
PopinConnectingDialog
PopinConnectingDialog
is a built-in dialog that shows a "Connecting..." message during the call initialization process.
To show the dialog:
PopinConnectingDialog cdd = new PopinConnectingDialog(MainActivity.this);
cdd.show();
You can customize the appearance by modifying its layout or message as needed.
🔚 Conclusion
You’ve now successfully integrated PopinAndroidSDK into your Android application for enabling video calls. This setup handles user initiation, UI feedback during connection, and real-time event handling via listener callbacks.
Last updated