Let's integrate our SDK in few minutes

Quick Start#

Audio/Video Call SDKs for Android#

With CONTUS MirrorFly Call SDK for Android, you can easily add real-time call features to your client app within 30 minutes.

Through our client SDK, you can initialize and configure call into your app with minimal efforts.

Note : If you're looking for the fastest way to build your app’s UI with MirrorFly Call SDKs, you can use our sample apps. To get our sample apps, click here

Getting Started#


The requirements for call SDK for Android are:

  • Android Lollipop 5.0 (API Level 21) or above
  • Java 7 or higher
  • Gradle 4.1.0 or higher

Things To Be Noted Before You Get Started#

SDK License Key#


Skip this step if you are already having your license key.

To integrate MirrorFly Call SDK into your app, you will need a SDK License Key. The MirrorFly server will use this license key to authenticate the SDK in your application.

To get the License Key,#

Step 1: Sign up for a MirrorFly Account

Step 2: Log into your Account

Step 3: Get the License key from the application Info’ section


Integrate the Call SDK#

Step 1: Create a new project or Open an existing project in Android Studio

Step 2: If using Gradle 6.8 or higher, add the following code to your settings.gradle file. If using Gradle 6.7 or lower, add the following code to your root build.gradle file. See this release note to learn more about updates to Gradle.

dependencyResolutionManagement {
repositories {
maven {
url "https://repo.mirrorfly.com/release"


Step 3: Add the following dependencies in the app/build.gradle file.

dependencies {
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.4.0'


Step 4: Add the below line in the gradle.properties file, to avoid imported library conflicts.


Step 5: Open the AndroidManifest.xml and add below permissions.

<uses-permission android:name="android.permission.INTERNET" />

Initialize Chat SDK#

To start using the sdk, there is a need for some basic requirements before proceeding with the initialization process. Thus, the ChatSDK builder class is used to provide the necessary data to the SDK. In your Application class, inside the onCreate() method use the below ChatSDK Builder to provide the necessary data.


new ChatSDK.Builder()
.setLicenseKey(LICENSE_KEY) //Please enter your license key

Chat Builder Function Description#

FunctionParameter TypeDescription
setDomainBaseUrlStringUrl is provided to make API calls
setLicenseKeyStringLicense key is required to proceed with registration
setIsTrialLicenceKeybooleanIf the provided license key is for trial version, display the text as ‘true’ else ‘false’
buildn/aInitializes the chat configuration

The base URL must have the Http/Https protocol which must be closed with a ‘slash (/)’, if not an exception - a bug message will pop up.



Skip this step if you are already completed the Registration in your application.

The below method to register a user in sandbox Live mode based on setIsTrialLicenceKey provided.


Unless you log out the session, make a note that should never call the registration method more than once in an application

Note: While registration, the below registerUser method will accept the FCM_TOKEN, FORCE_REGISTER, USER_TYPE and LIST<METADATA> as an optional param and pass it across.

FlyCore.registerUser(USER_IDENTIFIER, (isSuccess, throwable, data ) -> {
if(isSuccess) {
Boolean isNewUser = (Boolean) data.get("is_new_user");
JSONObject responseObject = (JSONObject) data.get("data");
// Get Username and password from the object
} else {
// Register user failed print throwable to find the exception details.
USER_IDENTIFIERStringA unique Id to Register the User. We accept only the AlphaNumeric String
FCM_TOKENStringA registration token that is generated by FCM SDK for the user's app instance to send message for free
FORCE_REGISTERbooleandefault value true provide true to force the logout of the old session If the registered user has reached the maximum no of multi-sessions or provide false to allow registration till the maximum no of multi-sessions
USER_TYPEStringtype of the user
META_DATAList<MetaData>list of key - value pair of metadata object. Maximum size is 3
CALLBACKFlyCallbackFlyCallback is used as a callback, implemented and expressed as lambda expression for easy reading

If FORCE_REGISTER is false and it reached the maximum no of multi-sessions then registration will not succeed it will throw a 405 exception, Either FORCE_REGISTER should be true or one of the existing session need to be logged out to continue registration.

Connect to the Chat Server#

Once Registration was successful, ChatSDK automatically attempts to connect to the Chat Server and ChatSDK also observe the changes in application lifecycle, and accordingly it will try to connect and disconnect the Chat Server.

Observe Connection Events#

Once the ChatConnectionListener has been set, you will be able to receive the connection status in the callback method as mentioned below.

ChatManager.setConnectionListener(new ChatConnectionListener() {
public void onConnected() {
// Write your success logic here to navigate Profile Page or
// To Start your one-one chat with your friends
public void onDisconnected() {
// Connection disconnected
public void onConnectionFailed(@NonNull FlyException e) {
// Connection Not authorized or Unable to establish connection with server
public void onReconnecting() {
// Automatic reconnection enabled
CALLBACKChatConnectionListenercallback listener for chat connection


Some of the most common terminologies used in Chat SDK with description

userID/userBareIDUnique ID assigned for each user Ex: 12345678 (any alphanumeric). The below characters is not allowed in userId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@) userID should follow below specification: https://xmpp.org/extensions/xep-0106.html
userJid (or) JIDuserID+@+domain of the chat server Ex. 12345678@xmpp.chatsystem.dev.contus.us
groupID/groupBareIDUnique ID assigned for each group Ex: group123456 (any alphanumeric). GroupJID = groupID +@mix.+domain of the chat server Ex: group123456@mix.xmpp.mirrorfly.dev.contus.us`

SDK will have built-in functions to prepare the JID, Group JID, and more.

Initialize Call SDK#

In your Application class, inside the onCreate() method add the below lines:

CALL_UI_ACTIVITYClassActivity which needs to be invoked during incoming call. when a incoming call is received Call sdk will start this activity with the call details
public void onCreate() {
//Initialize call manager
//set your call activity
CallManager.setMissedCallListener((isOneToOneCall, userJid, groupId, callType, userList) -> {
//show missed call notification
CallManager.setCallHelper(new CallHelper() {
public String getNotificationContent(@NonNull String callDirection) {
return CallNotificationHelper.getNotificationMessage();
public void sendCallMessage(@NotNull GroupCallDetails details, @NotNull List<String> users, @NotNull List<String> invitedUsers) {
CallMessenger.sendCallMessage(details, users, invitedUsers);
CallManager.setCallNameHelper(new CallNameHelper() {
public String getDisplayName(@NonNull String jid) {
return ContactManager.getDisplayName(jid);

Note: setCallNameHelper is optional, if it is not configured then user name will be empty in the incomming and ongoing call notification. Note: sendCallMessage method is used to send initial calling payload to the callee

Setup your call activity#

Call UI Activity should be defined like below in your manifest

tools:targetApi="o_mr1" />

You need to call the below method on your call activityonCreate() to configure the call activity.

ACTIVITYActivityinstance of the call activity

You need to call the below method on onStart() from your call activity to notify the call sdk to remove the ongoing call notification.


You need to call the below method on onStop() from your call activity to notify the call sdk to show the ongoing call notification.


Make a call#

Call feature is essential for the modern day communication. Call sdk allows users to make a one to one audio/video call with the another sdk user.

Note: You need to check the required runtime permissions before calling call sdk methods. if required permissions are not available isSuccess will be false and error message will be given in callback.

Required runtime permissions#

For audio call, we need a below permissions:


You can use the below method to check audio call permissions:


From Android 12, ensure that android.permission.BLUETOOTH_CONNECT and android.permission.READ_PHONE_STATE runtime permissions are granted for your app for seameless audio routing and gsm call handling. If the android.permission.BLUETOOTH_CONNECTpermission is not granted, call audio will not be routed to BT Headset even though it is connected. If the android.permission.READ_PHONE_STATE permission is not granted, gsm call related functionalities will not work in sdk.

Note: From Android 13, CallSDK need below permission to show ongoing call notification.


You can use the below method to check call notification permission:


Make a voice call#

Make voice call feature allows users to make a one to one audio call with the another sdk user. You can make a voice call using the below method.

CallManager.makeVoiceCall("TO_JID", (isSuccess, message) -> {
TO_JIDStringjid of the call receiver
CALLBACKCallActionListenercallback to observe the action status

If one to one call feature unavailable for your plan then it will throw 403 exception.

Receive a call#

Whenever you receive the audio call from the another sdk user, call sdk will show notification if device android version is greater than or equal to Android 10 (API level 29), otherwise the activity which you set using the CallManager.setCallActivityClass() method during call sdk initialisation will be started with the call details. sample call ui will be available for quick integration.


Please don't forget to set activity class for call sdk using CallManager.setCallActivityClass().

Answer the call#

Whenever you receive the audio call from the another sdk user, depending upon the android version, you activity may be started so whenever user presses accept button from your call UI , you need to call the below sdk method to answer the call and notify the caller.

Note: if the required permissions are not available then call be will be automatically declined even though you answered a call

CALLBACKCallActionListenercallback to observe the action status
CallManager.answerCall((isSuccess, message) -> {

Decline the call#

Whenever you receive the audio call from the another sdk user, depending upon the android version, you activity may be started so whenever user presses decline button from your call UI , you need to call the below sdk method to decline the call and notify the caller.


Disconnect the ongoing call#

Whenever you make the audio call to the another sdk user and you just want to disconnect the call before getting connected or if you want to just disconnect a connected call after the end of conversation, whenever user presses the disconnect button from your call UI , you need to call the below sdk method to disconnect the call and notify the caller.

Note: The below method accepts CallActionListener as a optional paramter. you can pass the listener to get disconnect success callback