Dial out with phone audio
The code on this page works with either the default UI or the custom UI.
In some scenarios, you may want to use phone audio instead of VoIP audio. Use the SDK to call your phone number or to get the dial-in phone numbers and dial into the meeting to connect to meeting audio. The PhoneHelper interface handles most of this functionality.
Prerequisites
- The meeting host account is Pro or above.
- The host account subscribes to the Audio Plan add-on.
Verify feature support
Before using any phone functionality, use the method isSupportPhoneFeature to check whether the meeting supports basic phone features such as joining the meeting by phone. Then use the isDialoutSupported method to check if the meeting supports Call me or Invite participants by phone functionality.
val phoneHelper = ZoomSDK.getInstance().meetingService.phoneHelper
if (phoneHelper.isSupportPhoneFeature) {
// Phone audio is supported
If (phoneHelper.isDialoutSupported) {
// Support phone dial-out features
}
}
PhoneHelper phoneHelper = ZoomSDK.getInstance().getMeetingService().getPhoneHelper();
if (phoneHelper.isSupportPhoneFeature()) {
// Phone audio is supported
If (phoneHelper.isDialoutSupported()) {
// Support phone dial-out features
}
}
Call in to the meeting
Instead of directly dialing out to a number, you can display a phone number for the user to call. getCurrentMeetingCallInNumber provides a list of call-in numbers for the current meeting.
val callInNumbers = phoneHelper.currentMeetingCallInNumber
List<PhoneHelper.CallInPhoneNumberInfo> callInNumbers = phoneHelper.getCurrentMeetingCallInNumber();
After getting the call in numbers, iterate through them to access data related to each number.
callInNumbers.forEach { numberInfo ->
numberInfo.code
numberInfo.displayNumber
numberInfo.id
numberInfo.name
numberInfo.number
numberInfo.type
}
callInNumbers.forEach(callInPhoneNumberInfo -> {
callInPhoneNumberInfo.getCode(); // country code
callInPhoneNumberInfo.getDisplayNumber(); // whole display phone number ( country code + number)
callInPhoneNumberInfo.getID(); // country id
callInPhoneNumberInfo.getNumber(); // call-in number
callInPhoneNumberInfo.getName(); // country name
callInPhoneNumberInfo.getType(); // phone number's call type
});
The phone number's call types can be either toll or toll-free.
- CallInNumberType_TOLL - Toll numbers
- CallInNumberType_TOLLFREE - Toll-free number
- CallInNumberType_NONE - None of the above
Start the phone call
To initiate phone audio, use the callMe method, providing the country code and phone number of the current user, to call the current user's phone as the meeting audio.
phoneHelper.callMe(COUNTRY_CODE, PHONE_NUMBER)
phoneHelper.callMe(COUNTRY_CODE, PHONE_NUMBER);
You can also add a phone-audio-only user by providing the country code, phone number, and username. The username can be any value, but should be something identifiable and related to the user since it's visible to other participants in the meeting.
phoneHelper.inviteCallOutUser(COUNTRY_CODE, PHONE_NUMBER, USERNAME)
phoneHelper.inviteCallOutUser(COUNTRY_CODE, PHONE_NUMBER, USERNAME);
To end an in-session call, use the hangUp method.
phoneHelper.hangUp()
phoneHelper.hangUp();
Get status updates
To get updates about the phone audio's call out status, implement the PhoneHelperListener interface.
val phoneListener = object : PhoneHelperListener {
override fun onInviteCallOutUserStatus(
status: PhoneHelper.PhoneStatus?,
reason: PhoneHelper.PhoneFailedReason?
) = Unit
override fun onCallMeStatus(
status: PhoneHelper.PhoneStatus?,
reason: PhoneHelper.PhoneFailedReason?
) = Unit
}
phoneHelper.addListener(phoneListener)
PhoneHelperListener phoneListener = new PhoneHelperListener() {
@Override
public void onInviteCallOutUserStatus(PhoneHelper.PhoneStatus phoneStatus, PhoneHelper.PhoneFailedReason phoneFailedReason) {
// Get invite call out user status
}
@Override
public void onCallMeStatus(PhoneHelper.PhoneStatus phoneStatus, PhoneHelper.PhoneFailedReason phoneFailedReason) {
// Get call me status
}
};
phoneHelper.addListener(phoneListener);
Within the listeners, get updates to PhoneStatus to know if a call is active and whether the request was successful.
PhoneStatus_Calling- The phone call is connecting.PhoneStatus_Ringing- The phone call is connected and waiting for the other end to answer.PhoneStatus_Accepted- The phone call has been answered.PhoneStatus_Success- The phone call was successful.PhoneStatus_Failed- The phone call has failed.PhoneStatus_Canceling- The phone call is being cancelled.PhoneStatus_Canceled- The phone call has been successfully cancelled.PhoneStatus_Cancel_Failed- The SDK was unable to cancel the call.PhoneStatus_Timeout- The call timed out.PhoneStatus_None- Status unknown.
If a call fails, learn what caused the failure through the PhoneFailedReason enum.
PhoneFailedReason_Busy- The number dialed was busy.PhoneFailedReason_Not_Available- The number dialed was disconnected or otherwise unable to connect.PhoneFailedReason_User_Hangup- The phone number terminated the connection by hanging up.PhoneFailedReason_No_AnswerThe phone call was not answered.PhoneFailedReason_Block_No_Host- The call was not allowed because the host is not present.PhoneFailedReason_Block_High_Rate- // The system blocks invite by phone due to the high cost.PhoneFailedReason_Block_Too_Frequent- The rate limit for this feature has been hit. Please wait and try again later.PhoneFailedReason_Other_Fail- The call failed for another reason.PhoneFailedReason_None- The status was not related to a failure.
Access call data
After a call has started, access additional data about the active call.
callMeStatus- The status of the call started by thecallMemethod.inviteCallOutUserStatus- The status of the call started by theinviteCallOutUsermethod.supportCountryInfo- A list of supported countries for the meeting. EachPhoneSupportCountryInfoobject has 3 fields.countryCode- The country code at the start of the phone number.countryID- A unique identifier associated with the country.countryName- A human-readable name of the country.
phoneHelper.callMeStatus
phoneHelper.inviteCallOutUserStatus
phoneHelper.supportCountryInfo.forEach { countryInfo ->
countryInfo.countryCode
countryInfo.countryID
countryInfo.countryName
}
phoneHelper.getCallMeStatus();
phoneHelper.getInviteCallOutUserStatus();
phoneHelper.getSupportCountryInfo().forEach(countryInfo -> {
countryInfo.getCountryCode(); // country code
countryInfo.getCountryName(); // country name
countryInfo.getCountryID(); // country id
});
End the call and remove the listener
When you are no longer using phone audio, remove the listener.
phoneHelper.removeListener(phoneListener)
phoneHelper.removeListener(phoneListener)