Making a call

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:

Manifest.permission.RECORD_AUDIO
Manifest.permission.READ_PHONE_STATE

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

CallManager.isAudioCallPermissionsGranted();

For video call, we need below permissions:

Manifest.permission.RECORD_AUDIO
Manifest.permission.CAMERA
Manifest.permission.READ_PHONE_STATE

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

CallManager.isVideoCallPermissionsGranted();

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.

Manifest.permission.POST_NOTIFICATIONS

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

CallManager.isNotificationPermissionsGranted();
ArgumentTypeDescription
TO_JIDStringjid of the call receiver
CALLBACKCallActionListenercallback to observe the action status

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) -> {
});
caution

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

Make a video call#

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

CallManager.makeVideoCall("TO_JID", (isSuccess, message) -> {
});
caution

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

Make a group voice call#

Make group voice call feature allows users to make a voice call with multiple sdk users. You can make a group voice call using the below method.

ArgumentTypeDescription
JID_LISTList<String>jid list of the callee's
GROUP_IDStringGroup id of the group from which call initiated
CALLBACKCallActionListenercallback to observe the action status
CallManager.makeGroupVoiceCall(JID_LIST, GROUP_ID, (isSuccess, message) -> {
});
caution

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

Make a group video call#

Make group video call feature allows users to make a video call with multiple sdk users. You can make a group video call using the below method.

CallManager.makeGroupVideoCall(JID_LIST, GROUP_ID, (isSuccess, message) -> {
});
caution

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

Add participants to the call#

After call is connected, you can able to add users to the ongoing call. sdk provides methods to invite users to the call, once they accepted the incoming call, they will join in the ongoing call.

ArgumentTypeDescription
JID_LISTList<String>jid list of the callee's
CallManager.inviteUsersToOngoingCall(JID_LIST);
caution

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

Receiving a incoming audio/video call#

Whenever you receive the audio/video 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.

caution

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

Answer the incoming call#

Whenever you receive the audio/video 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

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

Decline the incoming call#

Whenever you receive the audio/video 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.

CallManager.declineCall();

Disconnect the ongoing call#

Whenever you make the audio/video 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

CallManager.disconnectCall();
info

Call Sdk requires chat sdk integration for user management.